pub enum AgentMutation {
AppendMessage(Message),
AppendMessages(Vec<Message>),
IncrementIteration,
AddToolCalls(usize),
AddOutputTokens(usize),
AddReasoningTokens(usize),
IncrementCompactCount,
ReplaceMessages(Vec<Message>),
SetStopReason(StopReason),
SetLastResponse(ChatResponse),
}Expand description
Agent 领域事件 — 描述一次状态转换。
节点通过发射 Mutation 来变更状态,而非直接修改 AgentState 字段。
Mutation 是可序列化的、自包含的、不可变的。
Variants§
AppendMessage(Message)
追加一条消息到历史
AppendMessages(Vec<Message>)
追加多条消息到历史
IncrementIteration
进入下一轮迭代
AddToolCalls(usize)
记录工具调用数量
AddOutputTokens(usize)
记录输出 Token
AddReasoningTokens(usize)
记录推理 Token
IncrementCompactCount
记录一次压缩
ReplaceMessages(Vec<Message>)
替换消息历史(压缩场景)
SetStopReason(StopReason)
设置停止原因
SetLastResponse(ChatResponse)
更新最后一次 LLM 响应
Trait Implementations§
Source§impl Clone for AgentMutation
impl Clone for AgentMutation
Source§fn clone(&self) -> AgentMutation
fn clone(&self) -> AgentMutation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentMutation
impl Debug for AgentMutation
Source§impl<'de> Deserialize<'de> for AgentMutation
impl<'de> Deserialize<'de> for AgentMutation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 AgentMutation
impl Serialize for AgentMutation
Source§impl StateMutation<AgentState> for AgentMutation
impl StateMutation<AgentState> for AgentMutation
Auto Trait Implementations§
impl Freeze for AgentMutation
impl RefUnwindSafe for AgentMutation
impl Send for AgentMutation
impl Sync for AgentMutation
impl Unpin for AgentMutation
impl UnsafeUnpin for AgentMutation
impl UnwindSafe for AgentMutation
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