Skip to main content

AgentEvent

Enum AgentEvent 

Source
#[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 enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
RunStarted

A run began.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§run: RunId

The run.

§agent: AgentPath

The agent that runs it.

§

#[non_exhaustive]
RunEnded

A run ended; the last event of the run.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§run: RunId

The run.

§outcome: RunOutcome

How 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 enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§run: RunId

The run.

§turn: usize

The turn, counting from 1.

§

#[non_exhaustive]
TurnEnded

A turn ended.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§run: RunId

The run.

§turn: usize

The turn.

§tool_calls: usize

How many tool calls the turn made.

§

#[non_exhaustive]
RequestStarted

A request to the model was sent.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§request: RequestId

The request.

§prefix: PromptPrefix

The 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§request: RequestId

The request.

§usage: Option<Usage>

The usage the provider reported for it, if it did.

§outcome: RequestOutcome

How it ended.

§

#[non_exhaustive]
BlockDelta

A chunk of a block of the response.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§request: RequestId

The request.

§block: BlockId

The block within the request.

§kind: OutputKind

What the block is.

§text: String

The chunk.

§

#[non_exhaustive]
BlockEnded

A block of the response is complete.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§request: RequestId

The request.

§block: BlockId

The block.

§kind: OutputKind

What 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§call: ToolCallId

The call.

§name: String

The tool; empty in the earliest deltas of some providers.

§arguments_fragment: String

The next fragment of the JSON arguments.

§

#[non_exhaustive]
ToolCallStarted

A tool call was made.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§call: ToolCallId

The call.

§name: String

The tool.

§arguments: Value

The arguments as the model made them; the detail of a hosted call as a string.

§origin: ToolOrigin

Where the call runs.

§

#[non_exhaustive]
ToolCallDecided

The agent settled whether the call runs, and how.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§call: ToolCallId

The call.

§decision: ToolVerdict

What was decided.

§

#[non_exhaustive]
ToolProgress

A running tool reported progress.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§call: ToolCallId

The call.

§progress: Progress

The tool’s typed report.

§

#[non_exhaustive]
ToolCallEnded

A tool call ended.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§call: ToolCallId

The call.

§result: ToolResult

What 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§pause: PauseId

The pause.

§call: Option<ToolCallId>

The tool call that waits, if a tool call does.

§kind: ApprovalKind

What is waited for, as the embedder named it.

§subject: String

What the approval is about.

§

#[non_exhaustive]
Resumed

The pause ended.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§pause: PauseId

The pause.

§

#[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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§trigger: CompactionTrigger

Why it started.

§

#[non_exhaustive]
CompactionEnded

The compaction last started ended.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§outcome: CompactionOutcome

How 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§error: AgentError

Why the compaction failed.

§alerts_removed: usize

System alerts and reminders the cleanup removed.

§outputs_spilled: usize

Long tool outputs the cleanup moved to files.

§

#[non_exhaustive]
ContextInjected

A context source or a hook put a block into the conversation.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§source: SourceId

Who injected it.

§kind: InjectionKind

What 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 enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§child: AgentPath

The child’s path.

§name: String

The child’s name.

§prompt: String

What it was asked to do.

§

#[non_exhaustive]
SubagentEnded

A subagent ended.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§child: AgentPath

The child’s path.

§outcome: RunOutcome

How 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§run: RunId

The run.

§reason: CheckpointReason

Why the checkpoint was emitted.

§turn: usize

The turn.

§phase: ContextWindowPhase

The lifecycle phase of the assembled context window.

§message_count: usize

Number of recent conversation messages currently in memory.

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.

Source

pub const fn run_started(run: RunId, agent: AgentPath) -> Self

A run began.

Source

pub const fn run_ended(run: RunId, outcome: RunOutcome) -> Self

A run ended.

Source

pub const fn block_delta( request: RequestId, block: BlockId, kind: OutputKind, text: String, ) -> Self

A chunk of a block of a response.

Source

pub const fn block_ended( request: RequestId, block: BlockId, kind: OutputKind, ) -> Self

A block of a response is complete.

Source

pub const fn tool_call_started( call: ToolCallId, name: String, arguments: Value, origin: ToolOrigin, ) -> Self

A tool call was made.

Source

pub const fn tool_call_decided(call: ToolCallId, decision: ToolVerdict) -> Self

The call’s fate was settled.

Source

pub const fn tool_progress(call: ToolCallId, progress: Progress) -> Self

A running tool reported progress.

Source

pub const fn tool_call_ended(call: ToolCallId, result: ToolResult) -> Self

A tool call ended.

Source§

impl AgentEvent

Source

pub const fn run(&self) -> Option<&RunId>

The run this event belongs to, for the events that carry one.

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more