adk_event (erlang_adk v0.2.1)

View Source

adk_event - Immutable event records for the ADK event system.

Events are the fundamental unit of communication in the ADK 2.0 architecture. Every agent action, tool call, and state change is recorded as an event.

Summary

Functions

Deserialize an event from a map.

Check if this is the terminal event in an invocation.

Create a new immutable event record with auto-generated ID and timestamp. Author is the name of the agent or the binary string "user". Content can be text (binary), {tool_calls, List}, or {tool_response, ...}.

Create a new immutable event record with options. Opts can include: partial (boolean), is_final (boolean), actions (map), invocation_id (binary).

Serialize an event to a map for JSON encoding or persistence.

Attach a state delta map to an existing event.

Types

event/0

-type event() ::
          #adk_event{id :: binary(),
                     invocation_id :: binary(),
                     author :: binary(),
                     content :: term(),
                     actions :: map(),
                     timestamp :: integer(),
                     partial :: boolean(),
                     is_final :: boolean()}.

Functions

from_map(Map)

-spec from_map(Map :: map()) -> event().

Deserialize an event from a map.

is_final_response(Event)

-spec is_final_response(Event :: event()) -> boolean().

Check if this is the terminal event in an invocation.

new(Author, Content)

-spec new(Author :: binary(), Content :: term()) -> event().

Create a new immutable event record with auto-generated ID and timestamp. Author is the name of the agent or the binary string "user". Content can be text (binary), {tool_calls, List}, or {tool_response, ...}.

new(Author, Content, Opts)

-spec new(Author :: binary(), Content :: term(), Opts :: map()) -> event().

Create a new immutable event record with options. Opts can include: partial (boolean), is_final (boolean), actions (map), invocation_id (binary).

to_map(Event)

-spec to_map(Event :: event()) -> map().

Serialize an event to a map for JSON encoding or persistence.

with_state_delta(Event, Delta)

-spec with_state_delta(Event :: event(), Delta :: map()) -> event().

Attach a state delta map to an existing event.