adk_event (erlang_adk v0.7.0)
View SourceImmutable, versioned events for the ADK event system.
Events are the fundamental unit of communication in the Runner architecture. encode/1 and decode/1 are the checked persistence/JSON boundary. They deliberately accept only JSON values in generic fields; Erlang terms are not rendered with ~p because that loses type information and can leak internal values into an external protocol.
Summary
Functions
Decode either a canonical event map or a map persisted by v0.2.x. Maps without schema_version use the legacy decoder. New, unknown versions are rejected so that a future schema is never misinterpreted as version 1.
Decode canonical version-1 content produced by encode_content/1.
Encode an event to the canonical JSON-safe map representation.
Encode one event content value without constructing an event. This is useful for durable continuations which embed tool calls but must use exactly the same canonical representation as externally visible events.
Check whether this is the terminal event in an invocation.
Create a new immutable event with an auto-generated ID and timestamp. Author is the name of the agent or the binary string <<"user">>. Content can be text, tool calls, or a tool response.
Create a new immutable event with options. Options can include partial, is_final, actions, and invocation_id.
Attach a state delta map to an existing event.
Types
Functions
-spec codec_version() -> pos_integer().
-spec decode(map()) -> {ok, event()} | {error, codec_error()}.
Decode either a canonical event map or a map persisted by v0.2.x. Maps without schema_version use the legacy decoder. New, unknown versions are rejected so that a future schema is never misinterpreted as version 1.
-spec decode_content(term()) -> {ok, term()} | {error, codec_error()}.
Decode canonical version-1 content produced by encode_content/1.
-spec encode(event()) -> {ok, map()} | {error, codec_error()}.
Encode an event to the canonical JSON-safe map representation.
Tool-call tuples are represented as maps. A three-field call always has a thought_signature key and a four-field call always has both optional keys; JSON null represents Erlang undefined. This makes tuple arity survive a JSON encode/decode round trip.
-spec encode_content(term()) -> {ok, map()} | {error, codec_error()}.
Encode one event content value without constructing an event. This is useful for durable continuations which embed tool calls but must use exactly the same canonical representation as externally visible events.
Strict compatibility wrapper around decode/1. Prefer decode/1 when reading untrusted data.
Check whether this is the terminal event in an invocation.
Create a new immutable event with an auto-generated ID and timestamp. Author is the name of the agent or the binary string <<"user">>. Content can be text, tool calls, or a tool response.
Create a new immutable event with options. Options can include partial, is_final, actions, and invocation_id.
Strict compatibility wrapper around encode/1. Prefer encode/1 at external boundaries where a typed error can be handled.
Attach a state delta map to an existing event.