Skip to main content

execute_tool_context

Function execute_tool_context 

Source
pub fn execute_tool_context(tool_use: ToolUse) -> ExecuteToolContext
Expand description

An ExecuteToolContext for calling a tool-stage handler’s logic on its own: the mock-agent view of tool_context, no registered tool and a cancel signal that never fires. Interrupts work as in an agent, with ids middleware:executeTool:<toolUseId>:<name>.

use serde_json::json;
use strands::testing::execute_tool_context;
use strands::ToolUse;

let context = execute_tool_context(ToolUse::new("delete", "t-1", json!({})));
let error = context.interrupt("approve").unwrap_err();
assert_eq!(error.interrupts[0].id, "middleware:executeTool:t-1:approve");