How Stateless Mocks Teach LLM Agents Wrong Causal Models
Stateful simulators must replace mocks to teach agents how their actions change the world.

Stateless mocks can teach LLM agents the wrong model of cause and effect by giving responses that look right but ignore what the agent did before. For agents that write to APIs or carry out sequential tasks, testing needs stateful simulators that preserve those consequences and are continuously verified against the live services they represent.
Why LLM agents and stateless mocks are a natural but dangerous pairing
Stateless mocks are cheap, fast, and easy to spin up, which makes them a natural choice for agent development. They provide responses without requiring the team to build and maintain the world behind an API. Because an LLM call is itself stateless, this arrangement can also appear architecturally consistent.
That apparent consistency conflates two different properties. The model’s statelessness belongs to inference, while the environment’s statelessness is a choice made when building test infrastructure. MLflow’s agent state guide frames the dominant 2026 production pattern as a stateless model wrapped inside a stateful runtime. The surrounding system supplies the continuity that the model does not own. Nothing about stateless inference implies that the world an agent acts on should forget its actions.
Real APIs such as Stripe, GitHub, and Slack manage resources whose state persists across calls. Their behavior depends on more than the current request, because earlier operations constrain what can happen next. A test environment that leaves out those dependencies leaves out part of how the API works. Yet each response can still look right when seen on its own. That is what makes the pairing dangerous before any production failure occurs.
What a stateless mock actually teaches an agent about cause and effect
A stateless mock selects a response without maintaining the changes caused by earlier calls. A DELETE can succeed while the next GET still returns the resource. A charge that was already captured can appear available for capture again, and a message already posted can be posted identically without conflict. Each response may have the expected shape. The contradiction becomes visible only when the calls are understood as a sequence.
Through repeated exposure, this environment teaches that writes have no durable side effects. It also teaches that order does not matter and that a prior action does not constrain the next one. Consider a trajectory that deletes, lists, creates, and then lists again. If each response is independent of the preceding write, every turn reinforces the same false relationship between action and observation. The agent receives no consistent evidence that its actions update the world.
Training and evaluation expose this defect in different ways. Training can reinforce behavior that fits the fictional environment, while evaluation can accept that behavior without detecting its causal errors. Neither requires an obviously malformed response or a failed assertion. An environment that never enforces consequences cannot establish whether an agent understands them.
Where the broken causal model fails in production: sequential tasks and long-horizon work
An agent that treats duplicate writes as harmless may double-charge a card when it reaches a real API. An agent that treats deletion as inconsequential may try to use a resource it has already deleted. These are failures to understand what earlier valid requests have made possible or impossible.
The mismatch grows with the length of the task. A short, atomic call has few sequential dependencies that can go wrong, while a long-horizon task needs the agent to take the effects of earlier actions into account when deciding what to do next. An incorrect assumption about one write can therefore invalidate the logic of subsequent calls. The agent may also invoke endpoints in an order that violates the service’s business logic.
Coherent, well-formed calls operating on a world that no longer exists produce the most dangerous kind of failure: a silent one. A stateless test suite can still pass because its assertions share the same missing dependencies. Apple’s SimSAT research reports gains on OfficeBench and another benchmark from training on stateful trajectories, corroborating the importance of this distinction. Perrier and Bennett identify statelessness and stochasticity as properties that destabilize continuity and persistence in language model agents. The environment must therefore enforce causal continuity.
Why read-only training data doesn't fix this, even when it covers many APIs
Broader API coverage does not repair a missing relationship between writes and subsequent reads. Read-only call patterns teach an agent to retrieve information and reason over request-response pairs. They do not require it to account for a world changed by its own actions. Thousands of such examples can expand familiarity with interfaces without exercising that different skill.
Apple’s SimSAT paper identifies the limitation directly in training work that primarily focuses on read-only APIs. This training does not teach agents how to work in environments that have both reads and writes. A narrow set of services adds another problem, because an agent can overfit to their domain logic, limiting transfer to novel stateful environments. API breadth and causal coverage are separate requirements.
SimSAT also identifies why the gap is difficult to close. Tight coupling between environment construction and data synthesis makes broad stateful supervision expensive to build. Implementing executable APIs and populating their environments creates an engineering burden that encourages a return to stateless approaches. That explains the attraction of more mock data, but it does not make the substitute adequate.
What a stateful simulator must do that a stateless mock structurally cannot
A stateful simulator must remember and propagate world state across every call in a session. Its responses must look like those from the same endpoint and show what earlier writes changed. It must also enforce the ordering constraints and conflict rules of the API it represents. These are requirements for causal fidelity. Without them, an evaluation measures behavior against a different system.
The minimum standard is concrete. A DELETE must make the resource unavailable on subsequent GETs, and a charge capture must prevent a second capture. A posted message must show up in later list calls. The simulator must also support deterministic evaluation so that results can be reproduced across runs. Otherwise, changes in environmental behavior can be mistaken for changes in agent quality.
ClawsBench provides a concrete example of this design through five mock services, namely Gmail, Calendar, Docs, Drive, and Slack. Each is backed by SQLite with full state management and deterministic snapshot/restore. To check fidelity, it uses golden request-response pairs taken from real accounts and compares the mock responses at every step of the trajectory. That design makes clear that the decisive property is maintained state. Fault injection, including latency spikes, 429s, 503s, and malformed responses, can extend this foundation, but cannot replace it.
How continuous verification prevents simulators from drifting into the same fiction as mocks
A simulator must keep state, but agreeing with its own rules alone does not show that it matches the live API. A simulator can preserve every transition in its own model while the provider changes the rules. An enum can gain a value, a required field can be added, or a webhook payload can change shape. The simulated world remains coherent even as it becomes externally wrong.
Saved-response mocks make this drift easy to understand. A team updates a response, leaves it alone for months, and continues testing against it while the provider changes field optionality, pagination behavior, auth headers, or error formats. The suite stays green because neither side is compared with the other. Stateful simulators face the same exposure despite having richer behavior.
The structural defense is continuous verification against the live API before every release. Automated probe-based testing must compare the simulator’s responses with what production does on each supported endpoint, without relying on manual audits done from time to time. Published fidelity scores make that comparison accountable. A falling score shows drift before the wrong behavior becomes part of the agent’s training environment.
What stateful, verified simulators enable in CI and RL training that mocks cannot
CI magnifies the testing choice because the same environment is exercised repeatedly. Live API calls are slow to run, have rate limits, and need credentials. Stateless stubs remove those constraints but also remove the consequences that sequential agent tests need. Stateful simulators running locally without live credentials resolve that tradeoff by retaining causal behavior within a controlled environment. Their value is not simply faster execution, but repeatable tests of what the agent actually changed.
RL training places an additional demand on this design. Thousands of parallel environment instances must each be independently stateful, deterministic, and horizontally scalable. When instances share the limits of a live service or get responses that vary, it can be hard to tell how an agent’s actions led to its reward. Stateless mocks avoid the operational burden only by simulating that relationship incorrectly. Repeating the resulting trajectories at scale reinforces the defect.
Apple’s SimSAT research addresses the construction burden through LLM world models that synthesize diverse stateful supervision trajectories without requiring code-driven environments backed by databases. That approach targets the cost of creating broad training data, while reproducible evaluation still requires control over environmental variation. Stateful fault injection also helps test how an agent recovers. After latency, a 429, or a 503, the agent must continue in a world that reflects its earlier actions. Only then does the test establish whether recovery preserves the task’s logic.
What engineering teams should change about how they test API-calling agents
Read-only, single-call agents are the context in which stateless mocks are structurally adequate. Once a workflow includes writes or sequential calls, replace stateless stubs with an environment that preserves their effects. This boundary distinguishes testing an isolated exchange from testing behavior across changing state.
After establishing that causal structure, require continuous verification against the live API and published fidelity evidence. A simulator should not be accepted solely because its own state machine is consistent. Before evaluation, pre-seed it with realistic data so the agent can find, modify, and delete existing resources. An empty environment cannot demonstrate those behaviors. Then introduce faults as stateful tests, with recovery judged against the world the agent had already changed.
Only after those conditions hold should evaluation, CI, and training depend on the environment. For RL pipelines, add independent state, deterministic behavior, and horizontal scalability across parallel instances so that environmental variation does not poison the reward signal. The sequence matters because repeated execution amplifies whatever model of causality the environment encodes. Establish the consequences first, verify that they match the live API, and then scale the runs.


