Skip to main content

AgentEvent

Enum AgentEvent 

Source
pub enum AgentEvent {
Show 23 variants Token { content: String, }, ReasoningToken { content: String, }, ToolToken { tool_call_id: String, content: String, }, ToolStart { tool_call_id: String, tool_name: String, arguments: Value, }, ToolComplete { tool_call_id: String, result: ToolResult, }, ToolError { tool_call_id: String, error: String, }, ToolLifecycle { tool_call_id: String, tool_name: String, phase: String, elapsed_ms: Option<u64>, is_mutating: bool, auto_approved: bool, summary: Option<String>, error: Option<String>, }, NeedClarification { question: String, options: Option<Vec<String>>, }, TaskListUpdated { task_list: TaskList, }, TaskListItemProgress { session_id: String, item_id: String, status: TaskItemStatus, tool_calls_count: usize, version: u64, }, TaskListCompleted { session_id: String, completed_at: DateTime<Utc>, total_rounds: u32, total_tool_calls: usize, }, TaskEvaluationStarted { session_id: String, items_count: usize, }, TaskEvaluationCompleted { session_id: String, updates_count: usize, reasoning: String, }, TokenBudgetUpdated { usage: TokenBudgetUsage, }, ContextCompressionStatus { phase: String, status: String, }, ContextSummarized { summary: String, messages_summarized: usize, tokens_saved: u32, usage_before_percent: f64, usage_after_percent: f64, trigger_type: String, }, ContextPressureNotification { percent: f64, level: String, message: String, }, SubSessionStarted { parent_session_id: String, child_session_id: String, title: Option<String>, }, SubSessionEvent { parent_session_id: String, child_session_id: String, event: Box<AgentEvent>, }, SubSessionHeartbeat { parent_session_id: String, child_session_id: String, timestamp: DateTime<Utc>, }, SubSessionCompleted { parent_session_id: String, child_session_id: String, status: String, error: Option<String>, }, Complete { usage: TokenUsage, }, Error { message: String, },
}
Expand description

Represents events emitted during agent execution.

These events are streamed to clients via SSE to provide real-time feedback on agent progress, tool execution, and completion.

§Variants

§Text Generation

  • Token - Streaming text token
  • ReasoningToken - Streaming reasoning/thinking token (separate channel)

§Tool Execution

  • ToolStart - Tool execution started
  • ToolComplete - Tool finished successfully
  • ToolError - Tool execution failed

§User Interaction

  • NeedClarification - Agent needs user input

§Progress Tracking

  • TaskListUpdated - Task list created or modified
  • TaskListItemProgress - Individual item progress
  • TaskListCompleted - All items completed
  • TaskEvaluationStarted - Task evaluation began
  • TaskEvaluationCompleted - Task evaluation finished

§Context Management

  • TokenBudgetUpdated - Context budget changed
  • ContextCompressionStatus - Context compression lifecycle progress
  • ContextSummarized - Old messages summarized

§Sub-sessions (Async Spawn)

  • SubSessionStarted - A child session is created and scheduled to run
  • SubSessionEvent - Forwarded raw child event (full fidelity)
  • SubSessionHeartbeat - Periodic heartbeat while the child is running
  • SubSessionCompleted - Child session finished (completed/cancelled/error)

§Terminal Events

  • Complete - Execution finished successfully
  • Error - Execution failed

§Serialization

Events are serialized as JSON with a type field for discrimination:

{"type": "token", "content": "Hello"}
{"type": "complete", "usage": {"prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15}}

Variants§

§

Token

Text token generated by the LLM.

Fields

§content: String

Generated text content

§

ReasoningToken

Reasoning/thinking token generated by the LLM.

This is streamed separately from assistant answer tokens so the UI can choose whether and how to display model reasoning traces.

Fields

§content: String

Generated reasoning content

§

ToolToken

Streaming output emitted while a specific tool call is running.

This is used to render “live output” inside a tool-call card in the UI without mixing tool output into the assistant’s main token stream.

Fields

§tool_call_id: String

Tool call identifier that this output belongs to.

§content: String

Output chunk.

§

ToolStart

Tool execution started.

Fields

§tool_call_id: String

Unique tool call identifier

§tool_name: String

Name of the tool being executed

§arguments: Value

Tool arguments (JSON)

§

ToolComplete

Tool execution completed successfully.

Fields

§tool_call_id: String

Tool call identifier

§result: ToolResult

Tool execution result

§

ToolError

Tool execution failed.

Fields

§tool_call_id: String

Tool call identifier

§error: String

Error message

§

ToolLifecycle

Structured lifecycle event for tool execution tracking.

These events complement ToolStart/ToolComplete/ToolError with richer metadata (mutability, auto-approval, wall-clock timing) and are emitted by ToolEmitter (in bamboo-agent-tools).

Fields

§tool_call_id: String

Tool call identifier

§tool_name: String

Canonical tool name

§phase: String

Lifecycle phase: “begin”, “finished”, “error”, “cancelled”

§elapsed_ms: Option<u64>

Wall-clock milliseconds since the call began (None for begin)

§is_mutating: bool

Whether the tool mutates state (writes files, runs commands)

§auto_approved: bool

Whether execution was auto-approved (no user prompt needed)

§summary: Option<String>

Human-readable summary

§error: Option<String>

Error message (if phase == “error”)

§

NeedClarification

Agent needs clarification from the user.

Fields

§question: String

Question to ask the user

§options: Option<Vec<String>>

Optional predefined options

§

TaskListUpdated

Emitted when task list is created or updated.

Fields

§task_list: TaskList

Current task list state.

§

TaskListItemProgress

Emitted when a task item makes progress (delta update).

Fields

§session_id: String

Session identifier

§item_id: String

Item identifier

§status: TaskItemStatus

New item status

§tool_calls_count: usize

Number of tool calls made

§version: u64

Item version (for optimistic concurrency)

§

TaskListCompleted

Emitted when all task items are completed.

Fields

§session_id: String

Session identifier

§completed_at: DateTime<Utc>

Completion timestamp

§total_rounds: u32

Total agent rounds executed

§total_tool_calls: usize

Total tool calls made

§

TaskEvaluationStarted

Emitted when task evaluation starts.

Fields

§session_id: String

Session identifier

§items_count: usize

Number of items to evaluate

§

TaskEvaluationCompleted

Emitted when task evaluation completes.

Fields

§session_id: String

Session identifier

§updates_count: usize

Number of items updated

§reasoning: String

Evaluation reasoning

§

TokenBudgetUpdated

Emitted when token budget is prepared (after context truncation)

Fields

§usage: TokenBudgetUsage

Token budget details

§

ContextCompressionStatus

Emitted when host-side context compression lifecycle changes.

Fields

§phase: String

Compression phase label (for example: pre-turn, mid-turn).

§status: String

Compression status: started | completed | failed | skipped

§

ContextSummarized

Emitted when conversation context is summarized

Fields

§summary: String

Generated summary text

§messages_summarized: usize

Number of old messages summarized

§tokens_saved: u32

Tokens saved by summarization

§usage_before_percent: f64

Context usage percentage before compression

§usage_after_percent: f64

Context usage percentage after compression

§trigger_type: String

What triggered the compression: “auto” | “manual” | “critical”

§

ContextPressureNotification

Emitted when context pressure reaches warning or critical levels. Frontend should display this to the user as a proactive notification.

Fields

§percent: f64

Context usage as a percentage of the context window.

§level: String

Severity level: “warning” (70%) or “critical” (90%).

§message: String

Human-readable message describing the pressure state.

§

SubSessionStarted

A child session was spawned from a parent session (async background job).

Fields

§parent_session_id: String
§child_session_id: String
§title: Option<String>

Optional title (useful for UI lists).

§

SubSessionEvent

Forwarded raw child event to the parent session stream.

Child sessions are not allowed to spawn further sessions, so this should not nest.

Fields

§parent_session_id: String
§child_session_id: String
§

SubSessionHeartbeat

Heartbeat emitted while a child session is running.

Fields

§parent_session_id: String
§child_session_id: String
§timestamp: DateTime<Utc>
§

SubSessionCompleted

Child session finished (completed/cancelled/error).

Fields

§parent_session_id: String
§child_session_id: String
§status: String

One of: “completed” | “cancelled” | “error” | “skipped”

§

Complete

Agent execution completed successfully.

Fields

§usage: TokenUsage

Final token usage statistics

§

Error

Agent execution failed.

Fields

§message: String

Error message

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> AgentEvent

Returns a duplicate of the value. Read more
1.0.0 · 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<(), Error>

Formats the value using the given formatter. Read more
Source§

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

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<AgentEvent, <__D as Deserializer<'de>>::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 as Serializer>::Ok, <__S as Serializer>::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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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>,