Invocation context threaded through the agent pipeline.
Summary
Functions
Emit an event via the streaming callback if one is set.
Create a child context for a sub-agent.
Fork context for a parallel branch.
Get a value from temp state.
Put a value in temp state, returning updated context.
Types
@type t() :: %ADK.Context{ agent: any(), app_name: String.t() | nil, artifact_service: {module(), keyword()} | nil, branch: String.t() | nil, callbacks: [module()], credential_service: module() | nil, ended: boolean(), invocation_id: String.t(), memory_store: {module(), keyword()} | nil, on_event: (ADK.Event.t() -> any()) | nil, plugins: [{module(), term()}], policies: [module()], run_config: ADK.RunConfig.t() | nil, session_pid: pid() | nil, temp_state: map(), user_content: map() | nil, user_id: String.t() | nil }
Functions
@spec emit_event(t(), ADK.Event.t()) :: :ok
Emit an event via the streaming callback if one is set.
Uses the process dictionary to deduplicate: if an event with the same ID was
already emitted in this invocation, the call is a no-op. This allows both
LlmAgent (which emits events inline during execution) and Runner (which
emits at the end as a fallback) to call emit_event without double-firing.
This is called internally by agents and the runner to stream events in real-time
when an on_event callback is configured in the context.
Create a child context for a sub-agent.
Extends the branch path to include the child agent name, enabling branch-aware content filtering. The branch uses dot-delimited paths like Python ADK's invocation_id hierarchy.
Fork context for a parallel branch.
Examples
iex> ctx = %ADK.Context{invocation_id: "inv-1", branch: nil}
iex> child = ADK.Context.fork_branch(ctx, "searcher")
iex> child.branch
"searcher"
Get a value from temp state.
Put a value in temp state, returning updated context.