Skip to main content
Definable includes testing utilities that let you verify agent behavior without making real API calls. This keeps tests fast, deterministic, and free of cost.

MockModel

MockModel simulates model responses with pre-defined outputs:

Multiple Responses

For multi-turn or tool-calling scenarios, provide multiple responses. They are consumed in order:

Simulating Tool Calls

Provide tool call data to simulate the model requesting tool execution:

Custom Side Effects

Use side_effect for dynamic behavior:

Reasoning Content

Simulate models that produce reasoning:

Testing the Thinking Layer

Simulate the thinking phase with structured_responses. When the agent calls the model with a structured output format (for thinking), it consumes from structured_responses; normal calls consume from responses:

Inspecting Calls

MockModel tracks every call for assertions:

AgentTestCase

A base class for test suites with built-in assertion helpers:

Available Assertions

create_agent Helper

AgentTestCase.create_agent() creates agents with tracing disabled by default, keeping test output clean:

Quick Test Helper

For simple tests outside a test class, use create_test_agent:

Example with pytest