Skip to main content

tool_context

Function tool_context 

Source
pub fn tool_context(tool_use: ToolUse) -> ToolContext
Expand description

A ToolContext for running a tool on its own.

The agent view has the id mock-agent, a MockModel, empty state and no tools; interrupts work as in an agent, with ids tool:<toolUseId>:<name>.

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

let context = tool_context(ToolUse::new("echo", "t-1", json!({"text": "hi"})));
assert_eq!(context.agent().id(), "mock-agent");
assert_eq!(context.tool_use().input, json!({"text": "hi"}));