#[non_exhaustive]pub enum AgentEvent {
Show 22 variants
#[non_exhaustive] RunStarted {
run: RunId,
agent: AgentPath,
},
#[non_exhaustive] RunEnded {
run: RunId,
outcome: RunOutcome,
},
#[non_exhaustive] TurnStarted {
run: RunId,
turn: usize,
},
#[non_exhaustive] TurnEnded {
run: RunId,
turn: usize,
tool_calls: usize,
},
#[non_exhaustive] RequestStarted {
request: RequestId,
prefix: PromptPrefix,
},
#[non_exhaustive] RequestEnded {
request: RequestId,
usage: Option<Usage>,
outcome: RequestOutcome,
},
#[non_exhaustive] BlockDelta {
request: RequestId,
block: BlockId,
kind: OutputKind,
text: String,
},
#[non_exhaustive] BlockEnded {
request: RequestId,
block: BlockId,
kind: OutputKind,
},
#[non_exhaustive] ToolCallDelta {
call: ToolCallId,
name: String,
arguments_fragment: String,
},
#[non_exhaustive] ToolCallStarted {
call: ToolCallId,
name: String,
arguments: Value,
origin: ToolOrigin,
},
#[non_exhaustive] ToolCallDecided {
call: ToolCallId,
decision: ToolVerdict,
},
#[non_exhaustive] ToolProgress {
call: ToolCallId,
progress: Progress,
},
#[non_exhaustive] ToolCallEnded {
call: ToolCallId,
result: ToolResult,
},
#[non_exhaustive] Paused {
pause: PauseId,
call: Option<ToolCallId>,
kind: ApprovalKind,
subject: String,
},
#[non_exhaustive] Resumed {
pause: PauseId,
},
#[non_exhaustive] CompactionStarted {
trigger: CompactionTrigger,
},
#[non_exhaustive] CompactionEnded {
outcome: CompactionOutcome,
},
#[non_exhaustive] CompactionRecovery {
error: AgentError,
alerts_removed: usize,
outputs_spilled: usize,
},
#[non_exhaustive] ContextInjected {
source: SourceId,
kind: InjectionKind,
},
#[non_exhaustive] SubagentStarted {
child: AgentPath,
name: String,
prompt: String,
},
#[non_exhaustive] SubagentEnded {
child: AgentPath,
outcome: RunOutcome,
},
#[non_exhaustive] Checkpoint {
run: RunId,
reason: CheckpointReason,
turn: usize,
phase: ContextWindowPhase,
message_count: usize,
},
}Expand description
Events emitted during agent execution.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]RunStarted
A run began.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]RunEnded
A run ended; the last event of the run.
Fields
This variant is marked as non-exhaustive
outcome: RunOutcomeHow it ended.
#[non_exhaustive]TurnStarted
A turn began: one request to the model and the tool calls it makes.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]TurnEnded
A turn ended.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]RequestStarted
A request to the model was sent.
Fields
This variant is marked as non-exhaustive
prefix: PromptPrefixThe hash chain of its prompt prefix and what rewrote that prefix since the previous request, so a host can tell where a cache miss began.
#[non_exhaustive]RequestEnded
A request ended.
Fields
This variant is marked as non-exhaustive
outcome: RequestOutcomeHow it ended.
#[non_exhaustive]BlockDelta
A chunk of a block of the response.
Fields
This variant is marked as non-exhaustive
kind: OutputKindWhat the block is.
#[non_exhaustive]BlockEnded
A block of the response is complete.
Fields
This variant is marked as non-exhaustive
kind: OutputKindWhat the block is.
#[non_exhaustive]ToolCallDelta
The model is streaming a tool call’s name and arguments, before the call is assembled.
Fields
This variant is marked as non-exhaustive
call: ToolCallIdThe call.
#[non_exhaustive]ToolCallStarted
A tool call was made.
Fields
This variant is marked as non-exhaustive
call: ToolCallIdThe call.
origin: ToolOriginWhere the call runs.
#[non_exhaustive]ToolCallDecided
The agent settled whether the call runs, and how.
Fields
This variant is marked as non-exhaustive
call: ToolCallIdThe call.
decision: ToolVerdictWhat was decided.
#[non_exhaustive]ToolProgress
A running tool reported progress.
Fields
This variant is marked as non-exhaustive
call: ToolCallIdThe call.
#[non_exhaustive]ToolCallEnded
A tool call ended.
Fields
This variant is marked as non-exhaustive
call: ToolCallIdThe call.
result: ToolResultWhat the model reads of it.
#[non_exhaustive]Paused
Work is waiting on something outside the agent: an approval, or a question a tool put through the approver under a kind of its own.
Fields
This variant is marked as non-exhaustive
call: Option<ToolCallId>The tool call that waits, if a tool call does.
kind: ApprovalKindWhat is waited for, as the embedder named it.
#[non_exhaustive]Resumed
The pause ended.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]CompactionStarted
A compaction started: one forked alongside the run, or one run by
Agent::compact,
Agent::compact_when_idle or the
run itself at the pause point or on a cold cache.
Exactly one CompactionEnded follows, and no
other compaction starts before it. It is emitted on the stream of
whatever ends the compaction, which for one forked alongside a run may
be a later run or explicit compaction; one ended where no stream is
open finishes as CompactionOutcome::Discarded first thing on the
next stream the agent opens.
Fields
This variant is marked as non-exhaustive
trigger: CompactionTriggerWhy it started.
#[non_exhaustive]CompactionEnded
The compaction last started ended.
Fields
This variant is marked as non-exhaustive
outcome: CompactionOutcomeHow it ended.
#[non_exhaustive]CompactionRecovery
A compaction failed with the window at the pause point, so the context was cleaned and the compaction reruns on it now.
The cleanup removes system alerts and reminders and moves long tool outputs to files. When the rerun fails too the run fails; otherwise the run continues on the compacted window.
Fields
This variant is marked as non-exhaustive
error: AgentErrorWhy the compaction failed.
#[non_exhaustive]ContextInjected
A context source or a hook put a block into the conversation.
Fields
This variant is marked as non-exhaustive
kind: InjectionKindWhat kind of injection it was.
#[non_exhaustive]SubagentStarted
A subagent began. Its own events follow, tagged with its path.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]SubagentEnded
A subagent ended.
Fields
This variant is marked as non-exhaustive
outcome: RunOutcomeHow its run ended.
#[non_exhaustive]Checkpoint
A snapshot of the agent’s state was taken after it changed.
Fields
This variant is marked as non-exhaustive
reason: CheckpointReasonWhy the checkpoint was emitted.
phase: ContextWindowPhaseThe lifecycle phase of the assembled context window.
Implementations§
Source§impl AgentEvent
Constructors for the events an agent that lives outside this crate, such
as an external session run as a ChildAgent, can
report.
impl AgentEvent
Constructors for the events an agent that lives outside this crate, such
as an external session run as a ChildAgent, can
report.
Sourcepub const fn run_started(run: RunId, agent: AgentPath) -> Self
pub const fn run_started(run: RunId, agent: AgentPath) -> Self
A run began.
Sourcepub const fn run_ended(run: RunId, outcome: RunOutcome) -> Self
pub const fn run_ended(run: RunId, outcome: RunOutcome) -> Self
A run ended.
Sourcepub const fn block_delta(
request: RequestId,
block: BlockId,
kind: OutputKind,
text: String,
) -> Self
pub const fn block_delta( request: RequestId, block: BlockId, kind: OutputKind, text: String, ) -> Self
A chunk of a block of a response.
Sourcepub const fn block_ended(
request: RequestId,
block: BlockId,
kind: OutputKind,
) -> Self
pub const fn block_ended( request: RequestId, block: BlockId, kind: OutputKind, ) -> Self
A block of a response is complete.
Sourcepub const fn tool_call_started(
call: ToolCallId,
name: String,
arguments: Value,
origin: ToolOrigin,
) -> Self
pub const fn tool_call_started( call: ToolCallId, name: String, arguments: Value, origin: ToolOrigin, ) -> Self
A tool call was made.
Sourcepub const fn tool_call_decided(call: ToolCallId, decision: ToolVerdict) -> Self
pub const fn tool_call_decided(call: ToolCallId, decision: ToolVerdict) -> Self
The call’s fate was settled.
Sourcepub const fn tool_progress(call: ToolCallId, progress: Progress) -> Self
pub const fn tool_progress(call: ToolCallId, progress: Progress) -> Self
A running tool reported progress.
Sourcepub const fn tool_call_ended(call: ToolCallId, result: ToolResult) -> Self
pub const fn tool_call_ended(call: ToolCallId, result: ToolResult) -> Self
A tool call ended.