# `ADK.Context`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/context.ex#L1)

Invocation context threaded through the agent pipeline.

# `t`

```elixir
@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() -&gt; 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
}
```

# `emit_event`

```elixir
@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.

# `for_child`

```elixir
@spec for_child(t(), map()) :: t()
```

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_branch`

```elixir
@spec fork_branch(t(), String.t()) :: t()
```

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_temp`

```elixir
@spec get_temp(t(), term()) :: term() | nil
```

Get a value from temp state.

# `put_temp`

```elixir
@spec put_temp(t(), term(), term()) :: t()
```

Put a value in temp state, returning updated context.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
