An observe-only event emitted during a run.
on_event: receives these synchronously in the loop's process, in order; its
return value is ignored and an exception, throw or exit from it is caught and
does not change the run. It must return quickly: the library adds no queue or
backpressure, so a slow observer slows the loop.
step is the model turn the event belongs to, and is nil on :run_started
and :finished. run_id is the id of the run that emitted it; it is the same
on every event of a run and across a resume. Events are not stored: a caller
that wants a full history records them, because AgentCall.Result.transcript
is the model-visible context a policy may have replaced.
On the :error ending, tool_calls counts only the results of completed
turns, not the :tool_result events already emitted in the failing turn, so a
UI that counts those events can see a larger number.
:step_started carries the tool names this turn's request offers, sorted:
%{tools: [String.t()]}. A context: policy may have narrowed the set, so
this is not necessarily :run_started's tools:, which reports the run's
original set. It is the set the loop will also dispatch, so a name missing
here is a name the model cannot call.
:checkpoint is emitted after every completed tool turn, after all its
:tool_result events and before the next turn's :context_updated or
:step_started. Its step is the completed turn and its data is
%{checkpoint: %AgentCall.Checkpoint{}}. It is not emitted at a pause, after
a no-tool final answer or after a partial stream; those boundaries are a
%AgentCall.Pending{}, a %AgentCall.Result{} or an error, respectively.
:run_started reports the run's shape: resumed?:, stream?:, max_steps:,
max_concurrency:, tools:, context?:, prompt?:, cancel?: and
input_tools:, the names of the marked AgentCall.Input tools in
request.tools. Approval and input both end a run with :pending;
Pending.kind says which pause it is, and :approval_required /
:input_required carry the %AgentCall.Pending{}.
Summary
Types
@type t() :: %AgentCall.Event{ data: map(), run_id: String.t(), step: pos_integer() | nil, type: type() }
@type type() ::
:run_started
| :context_updated
| :step_started
| :text_delta
| :thinking_delta
| :tool_call_started
| :tool_result
| :checkpoint
| :step_finished
| :approval_required
| :input_required
| :finished