Taxonomy of API Dependency Mocking Strategies Across Agent Eval Frameworks
A guide to choosing between four mocking layers for agent evals.

To use an API for agent evals without hitting production, substitute at the boundary the eval needs to test. This taxonomy distinguishes HTTP interception, tool-level mocking, record/replay, and in-process stateful fakes. Use stateful fakes when later responses must follow from earlier actions and return API output that looks real.
Why agent eval results go wrong at the mocking layer
With live APIs, agent evaluation at a large scale takes time and money, and some actions cannot be undone. An agent’s tool calls also change state outside the agent, and its reasoning is non-deterministic. Substitution is therefore part of the test design. The risk begins when the chosen substitute removes behavior that the eval is supposed to verify, producing brittle tests or confidence in an integration that has not actually been exercised.
The Queen’s University empirical study of 39 open-source agent frameworks and 439 agentic applications found that both groups use test doubles to keep third-party integrations separate from what they test. Frameworks showed greater use of mock assertions and snapshot testing, reflecting stricter validation of integration behavior. Yet most of the testing effort went into deterministic tools and workflows, while less than 5% went into the FM-based plan body. Coverage does not automatically follow testing effort. Boundary confusion explains how extensive tests can still leave the intended agent behavior unexamined.
The four mocking layers and the boundaries they each target
HTTP interception operates at the network transport boundary, substituting responses to outbound HTTP calls while the agent’s tool implementation runs. Its contract includes URLs, headers, status codes, and raw response bodies. Tool-level mocking moves the boundary inward. It replaces the callable tool itself, so the eval exercises the interface between the reasoning loop and the tool without running the implementation beneath that interface.
Record/replay saves real exchanges and returns the recorded responses when the test runs again. Its defining boundary is temporal rather than architectural, because it reproduces a past interaction with the service. In-process stateful fakes instead maintain a local data model across requests. They target the dependency’s behavioral contract, including the way earlier mutations constrain later responses.
These strategies differ along two axes, namely how much of the real stack they exercise and whether they represent evolving state. Depth and statefulness are separate properties. A transport-level fixture can run the whole tool implementation without remembering a single mutation, while a fake can keep track of how resources relate to each other across calls. This is a reference map because each boundary answers a different kind of question.

What HTTP interception tests and what it cannot see
HTTP interception is appropriate when the eval concerns request serialization, header construction, response handling, or retry logic. The tool code runs in full. A substituted response can therefore expose how that code handles a 429 rate-limit response, a service-unavailable error, or malformed JSON without requiring the live service to produce that condition. The resulting evidence concerns the tool’s behavior at the wire contract.
In a fixture-based interceptor, each request gets a static response or one chosen by a condition, without taking earlier mutations into account. Consider an agent that creates a resource and then retrieves it by ID. The retrieval fixture can return a resource even if creation failed, or return data that has no link to the ID that creation returned. The apparent success then proves only that the agent handled the supplied responses.
Request matching can select a fixture using fields in the current request, with the dependency between an earlier action and the requested resource’s existence left unverified. HTTP interception is still useful for testing transport behavior on its own and choosing which errors to return. Its limit appears when the eval asks the response to represent a history.
What tool-level mocking tests and where it cuts the eval short
Tool-level mocking replaces a tool function with a deterministic stub before any HTTP code runs. The reasoning loop sees a callable with the expected signature and a controlled result. This isolates a narrow but important question. The eval can examine which tool the agent selects, the order of its calls, and the arguments it supplies without making the tool implementation part of the experiment.
The same study found that non-determinism-specific methods such as DeepEval appear in only a tiny fraction of agent tests, while negative and membership testing are widely adapted to manage FM uncertainty. Those patterns can help check reasoning when the test controls the outputs. They do not establish that the underlying integration works. A correct tool choice can coexist with a serialization defect that the stub prevents the eval from reaching.
The trade-off is control at the expense of implementation coverage. A stateless stub also cannot establish that returned data follows from prior calls. Even when it supplies a realistic-looking error, it does not test how the actual tool receives and translates that error from the service. Tool-level results therefore support conclusions about reasoning at the callable interface.
What record/replay buys you and the drift problem it cannot solve
Record/replay stores real HTTP exchanges and reuses them without network calls when the test runs again. At capture time, response fidelity is high because the service produced the recorded data. Repetition then becomes fast and deterministic. This makes recordings useful for documenting known-good behavior and regression-testing a known workflow against a fixed API version.
An existing cassette stays the same even when the service adds new required fields or changes its schemas, error codes, or business logic. The eval can continue to pass after the integration has broken. Its result establishes compatibility with the recorded service behavior.
ACCELQ’s governance framework identifies silent mock drift as one of three dangerous operational vectors in enterprise multi-squad microservice architectures, together with duplicated configurations and cascading pipeline failures. Drift is therefore an ownership problem as well as a fidelity problem. Authenticity at capture does not remove the need to account for later changes.
Dependent workflows add another source of brittleness. With cassettes keyed to request hashes, a new header or changed parameter can produce a cache miss, leading to an error or a live API call. Recorded values may be internally consistent for the captured sequence without supporting a different sequence generated by the agent. Record/replay preserves an interaction.
Why stateless mocking breaks multi-step agent workflows at the design level
Consider an agent that creates an order, receives an ID in a 201 response, polls that ID until the order is complete, and then attempts cancellation. The last request should get a 409 because an order that is complete cannot be cancelled. Every step depends on earlier state. A fixed status fixture can make polling finish immediately or never finish, while independent fixtures can disconnect the returned ID from the created order and leave the conflict path unreachable.
Static mocks provide one response per endpoint, while conditional mocks select responses from current request fields. Stateful mocks retain data between requests, and scripted mocks allow arbitrary per-request logic. Conditional behavior alone does not imply memory. The stateless forms of HTTP interception, tool mocking, and replay cannot enforce the causal relationship between a successful write and a later read.
APIFlow-Bench addresses this gap through long-horizon, dependent REST-API workflows. It separates seven engineering capabilities and composes cumulative workflows of up to 20 dependent subtasks within one evolving synthetic API world. That design distinguishes failures such as expired credentials, malformed payload fields, and unverified writes. For test suites, the lesson is selective statefulness. Most tests can remain stateless, but dependent workflows require stateful mocks with isolated data and serial execution mode.
In-process stateful fakes and what they can model that the other three layers cannot
An in-process stateful fake records mutations in an internal data model and answers requests from the accumulated state. Creation changes what later retrieval can return. If an agent creates an invoice, the invoice exists, contributes to account totals, and can be retrieved. If the agent deletes it, subsequent retrieval returns 404, so the eval can test the consequences of the agent’s actions.
A true API sandbox also remembers creation, updates, and deletion during a session, but an in-process fake does so without external network latency or live credentials. Its state can be reset or manipulated on demand. It can also be deliberately broken, allowing the workflow and its recovery behavior to be examined within the same modeled environment.
Persistence introduces a parallelism hazard in CI. Concurrent writes to shared fake state can make results non-deterministic even when each test is sound in isolation. To guard against this, each job should have its own fake instances or namespaced state.
Real API environments illustrate the boundaries a fake may need to reproduce. Stripe prevents objects created in test mode from being accessed in live mode, and a fake that replicates that separation can provide the corresponding guarantee without reaching Stripe’s servers. Kalshi provides a demo environment with mock funds and both REST and WebSocket interfaces, which can be used independently or together. These are distinct environment contracts. Realistic evaluation depends on representing the relevant behavior.
Fault injection as a first-class eval concern, not a layer of its own
Fault injection deliberately introduces latency, dropped connections, malformed responses, and permission denials into an API path. It is a capability that an implementation may provide at a chosen boundary. An eval concerned with resilience needs both explicit failures and responses that appear successful but omit or distort information the agent needs.
Network faults and semantic faults need different controls. Toxiproxy targets transport-layer latency and packet loss, while Istio/Envoy fault filters provide HTTP-level delays and aborts. A timeout exercises a different recovery path from a plausible but wrong field value that the agent accepts.
Programmable tool mocks and stateful fakes can supply such values, simulate partial record delivery, or introduce out-of-order webhook events. Their usefulness depends on the question being tested. A tool stub can isolate the reasoning response to bad data, while a stateful fake can model how that data interacts with later mutations and reads. For a resilient multi-step workflow, the latter makes it possible to test hard errors and silent semantic corruption without discarding the workflow’s history.
Matching the mocking layer to the eval question being asked
If the question is whether the agent chooses the right tool and supplies correct arguments, a tool-level mock isolates that reasoning boundary. The implementation does not need to run. If the question concerns serialization, retries, or response codes, HTTP interception keeps the tool implementation in the test while controlling the transport result.
If the question concerns a known historical interaction against a fixed API version, record/replay preserves that sequence. Its cassette must be refreshed on a schedule tied to API changes. If the test needs to check dependent resource IDs, state transitions, and realistic errors through a whole workflow, an in-process stateful fake gives it a world that keeps its state. Resilience adds another requirement. The fake must support programmable faults when the eval needs to test both explicit errors and misleading data within that world.
The benchmark’s seven capabilities illustrate why one layer is insufficient, covering authentication, discovery, schema repair, multistep execution, error recovery, pagination, and statefulness. The resulting eval pipeline is therefore a maintained set of test contracts. Mock configurations should be versioned with the test suite, owned at the squad level, and subject to automated schema drift detection regardless of the chosen layer.


