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 tokenReasoningToken- Streaming reasoning/thinking token (separate channel)
§Tool Execution
ToolStart- Tool execution startedToolComplete- Tool finished successfullyToolError- Tool execution failed
§User Interaction
NeedClarification- Agent needs user input
§Progress Tracking
TaskListUpdated- Task list created or modifiedTaskListItemProgress- Individual item progressTaskListCompleted- All items completedTaskEvaluationStarted- Task evaluation beganTaskEvaluationCompleted- Task evaluation finished
§Context Management
TokenBudgetUpdated- Context budget changedContextCompressionStatus- Context compression lifecycle progressContextSummarized- Old messages summarized
§Sub-sessions (Async Spawn)
SubSessionStarted- A child session is created and scheduled to runSubSessionEvent- Forwarded raw child event (full fidelity)SubSessionHeartbeat- Periodic heartbeat while the child is runningSubSessionCompleted- Child session finished (completed/cancelled/error)
§Terminal Events
Complete- Execution finished successfullyError- 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.
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.
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
ToolStart
Tool execution started.
Fields
ToolComplete
Tool execution completed successfully.
ToolError
Tool execution failed.
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
NeedClarification
Agent needs clarification from the user.
Fields
TaskListUpdated
Emitted when task list is created or updated.
TaskListItemProgress
Emitted when a task item makes progress (delta update).
Fields
status: TaskItemStatusNew item status
TaskListCompleted
Emitted when all task items are completed.
Fields
TaskEvaluationStarted
Emitted when task evaluation starts.
TaskEvaluationCompleted
Emitted when task evaluation completes.
Fields
TokenBudgetUpdated
Emitted when token budget is prepared (after context truncation)
Fields
usage: TokenBudgetUsageToken budget details
ContextCompressionStatus
Emitted when host-side context compression lifecycle changes.
Fields
ContextSummarized
Emitted when conversation context is summarized
Fields
ContextPressureNotification
Emitted when context pressure reaches warning or critical levels. Frontend should display this to the user as a proactive notification.
Fields
SubSessionStarted
A child session was spawned from a parent session (async background job).
Fields
SubSessionEvent
Forwarded raw child event to the parent session stream.
Child sessions are not allowed to spawn further sessions, so this should not nest.
SubSessionHeartbeat
Heartbeat emitted while a child session is running.
SubSessionCompleted
Child session finished (completed/cancelled/error).
Fields
Complete
Agent execution completed successfully.
Fields
usage: TokenUsageFinal token usage statistics
Error
Agent execution failed.
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more