pub struct ToolRuntime<S>where
S: State,{
pub state: S,
pub tool_call_id: String,
pub config: RunnableConfig,
pub store: Option<Arc<dyn Store>>,
/* private fields */
}Expand description
Tool runtime context injected into tool execution
Provides access to graph state, configuration, and store during tool execution.
Fields§
§state: SCurrent graph state (read-only snapshot)
tool_call_id: StringCurrent tool call ID
config: RunnableConfigRuntime configuration
store: Option<Arc<dyn Store>>Cross-thread persistent store
Implementations§
Source§impl<S> ToolRuntime<S>where
S: State,
impl<S> ToolRuntime<S>where
S: State,
Sourcepub const fn new(
state: S,
tool_call_id: String,
config: RunnableConfig,
store: Option<Arc<dyn Store>>,
stream_tx: Option<UnboundedSender<Value>>,
tools_event_tx: Option<UnboundedSender<ToolsEvent>>,
) -> ToolRuntime<S>
pub const fn new( state: S, tool_call_id: String, config: RunnableConfig, store: Option<Arc<dyn Store>>, stream_tx: Option<UnboundedSender<Value>>, tools_event_tx: Option<UnboundedSender<ToolsEvent>>, ) -> ToolRuntime<S>
Create a new ToolRuntime instance
§Arguments
state- Current graph statetool_call_id- Tool call identifierconfig- Runtime configurationstore- Optional cross-thread persistent storestream_tx- Optional streaming sender for output deltastools_event_tx- Optional streaming sender for tool lifecycle events
Sourcepub fn emit_output_delta(&self, delta: &str)
pub fn emit_output_delta(&self, delta: &str)
Emit tool output delta for streaming
Allows tools to stream intermediate results during execution. If no streaming channel is configured, this is a no-op.
§Arguments
delta- Output delta fragment to stream
Sourcepub fn emit_tool_started(&self, tool_name: &str, node: &str, input: Value)
pub fn emit_tool_started(&self, tool_name: &str, node: &str, input: Value)
Emit tool started lifecycle event
Sends a [ToolsEvent::ToolStarted] through the tools event channel
when one is configured. If no channel is available, this is a no-op.
§Arguments
tool_name- Name of the tool being startednode- Node name where the tool is executinginput- Tool input as JSON value
Sourcepub fn emit_tool_finished(&self, output: Value, duration_ms: u64, success: bool)
pub fn emit_tool_finished(&self, output: Value, duration_ms: u64, success: bool)
Emit tool finished lifecycle event
Sends a [ToolsEvent::ToolFinished] through the tools event channel
when one is configured. If no channel is available, this is a no-op.
§Arguments
output- Tool output as JSON valueduration_ms- Execution duration in millisecondssuccess- Whether the tool execution succeeded