pub struct AgentNode {
pub name: String,
pub agent: ToolUseLoop,
pub prefix: String,
pub write_messages: bool,
pub write_stats: bool,
}Expand description
Agent 节点(包装 ToolUseLoop)。
执行后将以下字段写回 State(默认 key 可通过 builder 自定义):
{prefix}.messages— 完整对话历史(含工具调用与结果){prefix}.output— 最终回复纯文本{prefix}.iterations— LLM 调用轮次{prefix}.tool_calls— 工具调用总数{prefix}.stop_reason— 停止原因(“Complete” / “MaxIterations” / …)
Fields§
§name: String§agent: ToolUseLoop§prefix: StringState 中的 key 前缀,默认 “agent”
write_messages: bool是否写回完整 messages(默认 true)
write_stats: bool是否写回执行统计(默认 true)
Implementations§
Source§impl AgentNode
impl AgentNode
pub fn new(name: impl Into<String>, agent: ToolUseLoop) -> Self
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
设置 State key 前缀(默认 “agent”)。
写入的 key 为:{prefix}.messages、{prefix}.output 等。
Sourcepub fn with_write_messages(self, enabled: bool) -> Self
pub fn with_write_messages(self, enabled: bool) -> Self
控制是否将完整对话历史写回 State(默认 true)。
Sourcepub fn with_write_stats(self, enabled: bool) -> Self
pub fn with_write_stats(self, enabled: bool) -> Self
控制是否写入 iterations / tool_calls / stop_reason(默认 true)。
Trait Implementations§
Source§impl GraphNode for AgentNode
impl GraphNode for AgentNode
Source§fn execute_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut State,
sink: &'life2 Sender<GraphEvent>,
span_id: SpanId,
) -> Pin<Box<dyn Future<Output = Result<StreamNodeResult, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut State,
sink: &'life2 Sender<GraphEvent>,
span_id: SpanId,
) -> Pin<Box<dyn Future<Output = Result<StreamNodeResult, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
流式执行 — 使用 ToolUseLoop::execute_stream,转发 AgentEvent。
Auto Trait Implementations§
impl !RefUnwindSafe for AgentNode
impl !UnwindSafe for AgentNode
impl Freeze for AgentNode
impl Send for AgentNode
impl Sync for AgentNode
impl Unpin for AgentNode
impl UnsafeUnpin for AgentNode
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