Expand description
Test fixtures for code built on strands.
MockModel is a scripted model: give it assistant turns as content blocks, raw stream events
or errors, and it streams them back while recording every ModelRequest it receives.
test_agent builds an agent on one.
tool_context builds the context to run a tool on its own, invoke_model_context and
execute_tool_context the contexts of middleware handlers, injection_context the context
an injection callback receives, and HookRecorder records the hook events that fire.
Structs§
- Hook
Recorder - Records the hook events that fire, by event type name, in order.
- Mock
Model - A scripted model for tests.
- Mock
Turn - One scripted model response for
MockModel.
Functions§
- execute_
tool_ context - An
ExecuteToolContextfor calling a tool-stage handler’s logic on its own: themock-agentview oftool_context, no registered tool and a cancel signal that never fires. Interrupts work as in an agent, with idsmiddleware:executeTool:<toolUseId>:<name>. - injection_
context - An
InjectionContextformessageson a mock agent (idmock-agent, empty app state), to test an injection render callback or predicate on its own. - invoke_
model_ context - An
InvokeModelContextfor calling a model-stage handler’s logic on its own: themock-agentview and aMockModelas intool_context,messages, and no system prompt, tools or tool choice. Set the public fields for anything else. - test_
agent - An
Agentonmodel, with the printer off and no tools. Keep a clone of the model to inspect the requests it received. - tool_
context - A
ToolContextfor running a tool on its own.