Skip to main content

test_agent

Function test_agent 

Source
pub fn test_agent(model: MockModel) -> Agent
Expand description

An Agent on model, with the printer off and no tools. Keep a clone of the model to inspect the requests it received.

use strands::testing::{MockModel, test_agent};

let model = MockModel::new().with_turn("Hello");
let mut agent = test_agent(model.clone());
let result = agent.invoke("Hi").await?;
assert_eq!(result.to_string(), "Hello");
assert_eq!(model.requests().len(), 1);