pub enum AgentEvent {
Provider(ProviderEvent),
ToolStart {
tool_call_id: String,
name: String,
},
ToolEnd {
tool_call_id: String,
result: ToolCallResult,
},
Retry {
tool_call_id: String,
attempt: usize,
max_attempts: usize,
reason: String,
},
LoopEnd {
result: ToolUseResult,
},
LoopError {
error: LlmError,
iterations: usize,
messages: Vec<Message>,
},
}Expand description
Agent 层流式事件 — 封闭、强类型、exhaustive match
终态契约:
- 正常结束:
LoopEnd恰好一次,然后 channel 关闭 - 异常结束:
LoopError恰好一次,然后 channel 关闭 - 终态事件后不再发送任何事件
Variants§
Provider(ProviderEvent)
Provider 层事件
ToolStart
工具开始执行
ToolEnd
工具执行完成
Retry
工具重试
LoopEnd
Agent loop 正常结束(恰好一次,后不再发送)
Fields
§
result: ToolUseResultLoopError
Agent loop 异常结束(恰好一次,后不再发送)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgentEvent
impl RefUnwindSafe for AgentEvent
impl Send for AgentEvent
impl Sync for AgentEvent
impl Unpin for AgentEvent
impl UnsafeUnpin for AgentEvent
impl UnwindSafe for AgentEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more