ExAgent. RunContext
(ExAgent v2.1.0)
View Source
The context object threaded through dynamic instructions, tool calls and output validators during a single run.
It carries the user-supplied deps, the model, the full message history, the
accumulated token usage, per-tool retry counters and the current
step/position info. The :deps value is application-defined; document its
expected shape with @spec in your tools.
execution_scope is an opaque, ephemeral handle for ExAgent.run_child/4.
Run/parent/root identities and model_request_id correlate work without
treating model request counts as local loop steps. Never serialize the handle.
observability and trace_context are likewise ephemeral; framework delegation
explicitly carries them across task boundaries and restores prior context.
Summary
Functions
Build a fresh context for a run.
Types
@type t() :: %ExAgent.RunContext{ continuation: term(), deps: term(), execution_scope: ExAgent.ExecutionScope.t() | nil, idempotency_key: String.t() | nil, max_retries: non_neg_integer(), messages: [ExAgent.Message.t()], metadata: map(), model: ExAgent.Model.model(), model_request_id: String.t() | nil, observability: ExAgent.Observability.OpenTelemetry.t() | nil, parent_run_id: String.t() | nil, prompt: String.t() | nil, retries: %{required(String.t()) => non_neg_integer()}, retry: non_neg_integer(), root_run_id: String.t() | nil, run_id: String.t() | nil, run_step: non_neg_integer(), tool_call_id: String.t() | nil, tool_name: String.t() | nil, trace_context: term(), usage: ExAgent.Message.Usage.t() }