pub struct ToolNode { /* private fields */ }Expand description
Prebuilt node that executes tool calls from the last AI message in state.
Supports both regular Tool and RuntimeAwareTool instances.
When a runtime-aware tool is registered, it receives the current graph
state, store reference, and tool call ID via ToolRuntime.
By default, tool calls are executed serially. Call ToolNode::with_parallel
to enable concurrent execution of multiple tool calls within a single step.
Implementations§
Source§impl ToolNode
impl ToolNode
pub fn new(executor: SerialToolExecutor) -> Self
Sourcepub fn with_middleware(
executor: SerialToolExecutor,
middleware: Arc<MiddlewareChain>,
) -> Self
pub fn with_middleware( executor: SerialToolExecutor, middleware: Arc<MiddlewareChain>, ) -> Self
Create a ToolNode with middleware support.
Sourcepub fn with_parallel(self, parallel: bool) -> Self
pub fn with_parallel(self, parallel: bool) -> Self
Enable parallel execution of tool calls.
When enabled and multiple tool calls exist in the last AI message,
they are executed concurrently using futures::future::join_all.
Results are collected in the same order as the original tool calls.
Sourcepub fn with_store(self, store: Arc<dyn Store>) -> Self
pub fn with_store(self, store: Arc<dyn Store>) -> Self
Set the store reference for runtime-aware tool injection.
Sourcepub fn with_runtime_tool(self, tool: Arc<dyn RuntimeAwareTool>) -> Self
pub fn with_runtime_tool(self, tool: Arc<dyn RuntimeAwareTool>) -> Self
Register a runtime-aware tool.
When a tool call matches a registered runtime-aware tool by name,
it will be called with a ToolRuntime containing the current
graph state, store, and tool call ID.