Skip to main content

AgentEvent

Enum AgentEvent 

Source
pub enum AgentEvent {
Show 30 variants RunStarted { agent: String, task: String, }, TurnStarted { agent: String, turn: usize, max_turns: usize, }, LlmResponse { agent: String, turn: usize, usage: TokenUsage, stop_reason: StopReason, tool_call_count: usize, text: String, latency_ms: u64, model: Option<String>, time_to_first_token_ms: u64, }, ToolCallStarted { agent: String, tool_name: String, tool_call_id: String, input: String, }, ToolCallCompleted { agent: String, tool_name: String, tool_call_id: String, is_error: bool, duration_ms: u64, output: String, }, ApprovalRequested { agent: String, turn: usize, tool_names: Vec<String>, }, ApprovalDecision { agent: String, turn: usize, approved: bool, }, SubAgentsDispatched { agent: String, agents: Vec<String>, }, SubAgentCompleted { agent: String, success: bool, usage: TokenUsage, }, ContextSummarized { agent: String, turn: usize, usage: TokenUsage, }, RunCompleted { agent: String, total_usage: TokenUsage, tool_calls_made: usize, }, GuardrailDenied { agent: String, hook: String, reason: String, tool_name: Option<String>, }, GuardrailWarned { agent: String, hook: String, reason: String, tool_name: Option<String>, }, RunFailed { agent: String, error: String, partial_usage: TokenUsage, }, RetryAttempt { agent: String, attempt: u32, max_retries: u32, delay_ms: u64, error_class: String, }, DoomLoopDetected { agent: String, turn: usize, consecutive_count: u32, tool_names: Vec<String>, }, FuzzyDoomLoopDetected { agent: String, turn: usize, consecutive_count: u32, tool_names: Vec<String>, }, KillSwitchActivated { agent: String, reason: String, guardrail_name: String, }, SessionPruned { agent: String, turn: usize, tool_results_pruned: usize, bytes_saved: usize, tool_results_total: usize, }, AutoCompactionTriggered { agent: String, turn: usize, success: bool, usage: TokenUsage, }, SensorEventProcessed { sensor_name: String, decision: String, priority: Option<String>, story_id: Option<String>, }, StoryUpdated { story_id: String, subject: String, event_count: usize, priority: Option<String>, }, ModelEscalated { agent: String, from_tier: String, to_tier: String, reason: String, }, BudgetExceeded { agent: String, used: u64, limit: u64, partial_usage: TokenUsage, }, AgentSpawned { agent: String, spawned_name: String, tools: Vec<String>, task: String, }, TaskRouted { decision: String, reason: String, selected_agent: Option<String>, complexity_score: f32, escalated: bool, }, WorkflowNodeStarted { node: String, }, WorkflowNodeCompleted { node: String, }, WorkflowNodeFailed { node: String, }, ToolNameRepaired { agent: String, original: String, repaired: String, },
}
Expand description

Structured events emitted during agent and orchestrator execution.

All events carry the agent name for identification in multi-agent runs. Events are emitted synchronously via the OnEvent callback — keep handlers fast to avoid blocking the agent loop.

Variants§

§

RunStarted

Agent loop started.

Fields

§agent: String
§task: String
§

TurnStarted

A new turn in the agent loop.

Fields

§agent: String
§turn: usize
§max_turns: usize
§

LlmResponse

LLM call completed.

Fields

§agent: String
§turn: usize
§stop_reason: StopReason
§tool_call_count: usize
§text: String

Truncated LLM response text.

§latency_ms: u64

Wall-clock milliseconds for the LLM call.

§model: Option<String>

Model name from the provider, if available.

§time_to_first_token_ms: u64

Time-to-first-token in milliseconds (streaming only). 0 for non-streaming.

§

ToolCallStarted

Tool execution started.

Fields

§agent: String
§tool_name: String
§tool_call_id: String
§input: String

Truncated JSON string of tool input.

§

ToolCallCompleted

Tool execution completed.

Fields

§agent: String
§tool_name: String
§tool_call_id: String
§is_error: bool
§duration_ms: u64
§output: String

Truncated tool output content.

§

ApprovalRequested

Human approval requested.

Fields

§agent: String
§turn: usize
§tool_names: Vec<String>
§

ApprovalDecision

Human approval decision received.

Fields

§agent: String
§turn: usize
§approved: bool
§

SubAgentsDispatched

Orchestrator dispatched sub-agents.

Fields

§agent: String
§agents: Vec<String>
§

SubAgentCompleted

A sub-agent completed.

Fields

§agent: String
§success: bool
§

ContextSummarized

Context was summarized due to threshold.

Fields

§agent: String
§turn: usize
§

RunCompleted

Agent run completed successfully.

Fields

§agent: String
§total_usage: TokenUsage
§tool_calls_made: usize
§

GuardrailDenied

A guardrail denied an LLM response or tool call.

Fields

§agent: String
§hook: String

Which hook triggered the denial: "post_llm", "pre_tool", or "post_tool".

§reason: String
§tool_name: Option<String>

Set for pre_tool and post_tool denials, None for post_llm.

§

GuardrailWarned

A guardrail issued a warning but allowed the operation to proceed.

Fields

§agent: String
§hook: String

Which hook triggered the warning: "post_llm" or "pre_tool".

§reason: String
§tool_name: Option<String>

Set for pre_tool warnings, None for post_llm.

§

RunFailed

Agent run failed.

Fields

§agent: String
§error: String
§partial_usage: TokenUsage
§

RetryAttempt

An LLM retry attempt is about to happen (before the sleep).

Fields

§agent: String
§attempt: u32

Current attempt number (1-indexed).

§max_retries: u32

Maximum retries configured.

§delay_ms: u64

Delay in milliseconds before the retry.

§error_class: String

Classified error that triggered the retry.

§

DoomLoopDetected

Doom loop detected: the agent repeated identical tool calls too many times.

Fields

§agent: String
§turn: usize
§consecutive_count: u32

Number of consecutive identical turns.

§tool_names: Vec<String>

Tool names in the repeated batch.

§

FuzzyDoomLoopDetected

Fuzzy doom loop detected: the agent repeated the same tools with different inputs.

Fields

§agent: String
§turn: usize
§consecutive_count: u32

Number of consecutive fuzzy-identical turns.

§tool_names: Vec<String>

Tool names in the repeated batch.

§

KillSwitchActivated

Kill switch activated: a guardrail triggered an immediate agent termination.

Fields

§agent: String
§reason: String
§guardrail_name: String
§

SessionPruned

Session pruning truncated old tool results before an LLM call.

Fields

§agent: String
§turn: usize
§tool_results_pruned: usize

Number of tool results that were truncated.

§bytes_saved: usize

Total bytes removed across all truncated tool results.

§tool_results_total: usize

Total tool results inspected (pruned + skipped).

§

AutoCompactionTriggered

Auto-compaction was triggered due to context overflow.

Fields

§agent: String
§turn: usize
§success: bool

Whether compaction succeeded.

§usage: TokenUsage

Token usage from the compaction LLM call.

§

SensorEventProcessed

A sensor event was processed through the triage pipeline.

Fields

§sensor_name: String
§decision: String

“promote”, “drop”, or “dead_letter”

§priority: Option<String>
§story_id: Option<String>
§

StoryUpdated

A story was created or updated with new correlated events.

Fields

§story_id: String
§subject: String
§event_count: usize
§priority: Option<String>
§

ModelEscalated

Model cascade escalated from a cheaper tier.

Fields

§agent: String
§from_tier: String
§to_tier: String
§reason: String

“gate_rejected” or “tier_error”

§

BudgetExceeded

Token budget exceeded: the agent consumed more tokens than the configured limit.

Fields

§agent: String
§used: u64

Total tokens consumed (input + output) across all turns.

§limit: u64

The configured token budget limit.

§partial_usage: TokenUsage

Partial token usage accumulated before the budget was exceeded.

§

AgentSpawned

A dynamic agent was spawned at runtime by the orchestrator.

Fields

§agent: String
§spawned_name: String
§tools: Vec<String>
§task: String
§

TaskRouted

Task was routed to single-agent or orchestrator by the complexity analyzer.

Fields

§decision: String

“single_agent” or “orchestrate”

§reason: String
§selected_agent: Option<String>
§complexity_score: f32
§escalated: bool
§

WorkflowNodeStarted

A workflow node agent has started executing (emitted by the workflow executor).

Fields

§node: String
§

WorkflowNodeCompleted

A workflow node agent has completed executing (emitted by the workflow executor).

Fields

§node: String
§

WorkflowNodeFailed

A workflow node agent has failed (emitted by the workflow executor).

Fields

§node: String
§

ToolNameRepaired

LLM emitted an unknown tool name that was repaired via Levenshtein distance. The repair happens before permission/guardrail evaluation so the policy applies to the repaired name, not the typo.

Fields

§agent: String
§original: String
§repaired: String

Implementations§

Source§

impl AgentEvent

Source

pub fn type_name(&self) -> &'static str

Returns the serde tag name for this event variant (e.g. "run_started").

Matches the #[serde(tag = "type", rename_all = "snake_case")] tags without requiring JSON serialization.

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> AgentEvent

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
Source§

impl<'de> Deserialize<'de> for AgentEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,