Measuring Fidelity Gaps Between Simulated APIs and Production Endpoints in Tool-Calling Agent Evals
Simulators must match production in what agents see, change, and earn.

To use an API for agent evals without hitting production during each rollout, run tasks against a stateful simulator and grade both the execution trace and the resulting environment state. Measure fidelity separately at the observation, transition, and reward layers, then stress-test all three with controlled faults. Realistic responses alone are not enough because errors in what an agent sees, changes, and gets rewarded for compound.
Why the sim-to-real problem in robotics is the right frame for tool-calling agent evals
Liu et al. (KDD '26) argue that foundation model agent research treats robustness as a new problem when robotics and classical control already offer a framework for understanding it. A robotic policy trained in simulation must operate in a world that differs from its training environment. Tool-calling agents face the same structural shift when they move from curated benchmarks to stochastic production endpoints. A leaderboard score does not establish deployment reliability.
The Markov Decision Process framework gives this shift a vocabulary. Its classical elements are state, action, transition, and reward, while the observation describes what the agent can see of the environment. For an API-calling agent, those observations include the responses from tools, transitions include the changes that writes cause, and rewards show whether the task succeeded. The action gap also belongs in this framework, but the measurement discipline here focuses on observation, transition, and reward.
That narrowing makes the deployment gap easier to diagnose. A response can misrepresent the environment, a write can change it incorrectly, or a grader can approve an outcome that production would reject. These are different failures with different remedies.
What a fidelity gap actually is, and why it compounds across layers

A fidelity gap is a discrepancy between the environment an eval presents and the production environment the agent must operate in. At the observation layer, the discrepancy may concern field presence, data types, schemas, or language conventions in parameter values. At the transition layer, it concerns how calls change state. At the reward layer, it concerns whether the success signal captures operational costs, side effects, and required invariants. These discrepancies do not remain neatly separated.
An observation error can alter the agent’s next action, which then takes the trajectory into a different state. If the simulator also accepts a state change that production would reject, subsequent calls proceed from a false premise. The grader then assesses behavior that production could never have supported.
Liu et al. give multilingual tool calling as a concrete example of this compounding effect. An agent can understand the request and choose the right tool while using parameter values that break execution-level language conventions. Correct semantic intent does not guarantee an executable action. A simulator that overlooks those conventions can therefore conceal the failure before the reward rule even runs.
The diagnostic consequence is that fidelity cannot be reduced to response resemblance. A simulator may look convincing at the first call and become progressively less representative as the agent acts. Earlier errors shape the trajectories used for evaluation or training, so later scores inherit those distortions. The reward gap adds another discrepancy to the earlier ones.
Measuring the observation gap: schema drift and underdocumented API surfaces
Observation measurement starts by comparing the API contract with the responses production actually returns. Schema comparisons expose changes in fields and types, but a specification does not describe every enforced behavior. Undocumented error conditions remain outside that comparison. Invalid parameters, missing fields, and boundary values can reveal a surface that the simulator never modeled.
To measure that surface, an auxiliary LLM agent can probe edge cases against production and expose behaviors that need replication in the sandbox. This probing complements specification checks. The relevant measurements distinguish declared schema changes from mismatches between the declared contract and actual responses. Keeping those categories separate identifies whether the simulator follows an outdated contract or whether the contract itself omits production behavior.
ClawsBench illustrates the cost of an underdocumented tool surface. Agents without skill specifications produced over a thousand “unrecognized subcommand” errors by inventing CLI syntax that did not exist. Those errors make a particular failure visible and countable. Although the example concerns CLI commands, it shows why a plausible tool description is not evidence that the agent understands the executable interface.
Continuous integration must preserve that distinction over time. Spec-to-spec diffing with a tool such as oasdiff catches contract changes before merge, while post-deploy spec-to-reality monitoring detects divergence between the contract and production responses. Both gates must be build-blocking so that drift cannot silently corrupt later evals. Fidelity is a live measurement because a simulator’s accurate snapshot can become an outdated account of the API.
Measuring the transition gap: why stateless mocks cannot support multi-turn agent evals
Stateless mocks return canned responses without remembering earlier calls. That can be sufficient for an isolated integration test, but a multi-turn agent changes the environment it later observes. A write must affect subsequent reads. Once the agent takes an unanticipated path, independent canned responses cannot represent the cumulative effects of its actions.
This makes state handling an architectural decision. A call recorder can establish whether the agent invoked expected tools in an expected order. It cannot establish whether those calls left the environment in the right condition. A valid sequence that was not expected may complete the task, while the expected sequence may still damage unrelated data.
Agent-Diff (Pyskło et al., KDD '26) makes that distinction measurable through a state-diff contract. It compares sandbox snapshots from the beginning and end of task execution and defines success by whether the expected environment change occurred. The comparison also checks invariants on resources that should remain untouched. This separates the correctness of the outcome from the appearance of the process.
The key metric is state-diff accuracy, the fraction of tasks whose final environment state matches the expected diff. For agent evaluation, that measures task outcomes rather than call-sequence conformity. Its meaning still depends on the simulator implementing production-like transitions, because a correct diff inside an inaccurate world is not proof of production reliability. State comparisons also expose idempotency violations that a correct-looking trace can conceal.
SimSAT (Lee et al., Apple, 2026) shows what coherent state tracking enables for training. Its LLM simulator tracks state dynamically and supplies responses throughout complete multi-step trajectories. A shopping cart can be shown, have items removed across multiple calls, and then be shown again with those removals reflected.
Measuring the reward gap: when the eval's success signal diverges from production reality
The reward gap can persist even when responses and state transitions are faithful. A grader may recognize task completion while ignoring unauthorized changes, excessive cost, or unacceptable latency. Nothing has to crash for this gap to exist. The eval simply assigns success to behavior that does not satisfy production requirements.
Zhou et al. (COLM 2026) show how an overly accommodating evaluation environment inflates results. Their LLM-based user simulators were excessively cooperative, stylistically uniform, and lacked realistic frustration or ambiguity, creating an “easy mode” above the human baseline. The finding concerns user simulation, not API replication. Its relevance here is the same calibration problem faced by simplified reward rules that omit the feedback and constraints encountered in production.
Zhang et al. (2026) reveal a less obvious failure through evidence substitution. When tool output arrived as a file rather than inline, models skipped the simulator’s report and answered from a file they had created themselves. Both files held the same result, but digit truncation in the agent’s own copy led to wrong answers even though the trajectory looked correct. The wrong evidence source broke the answer.
Because the simulator was deterministic, a three-step offline audit covering build, exposure, and closure could locate the failure without a human or model judge. Final accuracy alone could not identify where the result was lost. Reward measurement therefore needs instrumentation at the point where the agent reads its evidence.
The checks compare outcome-calibration with human judgment, verify side-effect invariants, and account for cost and latency within the reward definition. These checks ask different questions and should remain distinguishable. Operational failures such as rate-limit behavior, cascading failures, and duplicate charges are especially hard to find when every task follows a happy path. That limitation makes controlled faults a required part of reward validation.
Fault injection as a mandatory fourth measurement pass across all three layers
Controlled timeouts, corrupted responses, and lost acknowledgments reveal agent behavior when the environment breaks. This is a fourth measurement pass across the existing layers. It does not introduce a fourth kind of fidelity gap.
Silent degradation is a particularly revealing observation test. A fault can execute the real function and corrupt only its returned text while preserving latency and token counts. Standard cost and latency telemetry then shows no anomaly. The agent still receives a false observation, so the eval must check the response, trajectory, and outcome to find what went wrong.
Crash-and-resume scenarios stress transitions in a different way. If the same state-mutating call executes twice, the environment can end in a condition the agent never intended. State-diff checks expose that idempotency failure even when the trace appears acceptable. The test requires an environment that can preserve the effects of the first execution and represent the effects of the second.
Timeouts also test the reward definition. An agent without effective recovery can increase its tool-call count while attempting to complete the task. If the reward ignores that extra operational cost, apparent success conceals degraded behavior.
Agent-Diff supports reproducible fault tests through deterministic, resettable sandboxed replicas. The same perturbation can be applied across runs and models without relying on a live endpoint to fail in the same way. A stateless mock has no persistent state to corrupt and restore.
Why stateful, continuously verified simulators are the only substrate that makes all three measurements meaningful
Each layer imposes a different requirement on the environment beneath the eval. Observation checks require current agreement with production. Transition checks require memory across calls. Reward checks need realistic starting conditions and a way to see outcomes, while fault tests need controlled perturbations and resets that work reliably.
Stateless mocks cannot represent cumulative writes, and recorded cassettes replay fixed sequences rather than reliably following the agent’s chosen path. Live sandbox environments expose real behavior but cannot provide the same deterministic, repeatable faults. A stateful, continuously verified simulator gives all these measurements the environment they need.
In practice, the evaluation architecture connects a task dataset to simulated APIs, records execution traces, and applies graders to both the evidence path and resulting state. Pre-seeded data prevents tasks from beginning in an artificially sparse world where success is too easy. With persistent state, a record that has been created appears in later list calls and disappears after it is deleted. Fault controls then test those same tasks under disruption rather than substituting an unrelated reliability exercise.
Rystic is one option in this category, providing stateful API simulators for workplace messaging, code hosting, payment processing, and prediction markets that remember earlier writes. Its simulators run locally and scale across thousands of containers, allowing transition-gap checks on every rollout, while its maintainers publish fidelity scores that make the remaining gap measurable.
The verification requirement remains independent of the platform choice. Rechecking against production before every release and retaining published fidelity measurements creates an auditable record of drift. Pre-seeding supports reward calibration, but does not replace a well-defined grader. Statefulness also makes it possible to measure transitions, but does not prove that every transition is accurate.
For reinforcement learning, the same distinction applies to generated training environments. SimSAT conditions simulated responses on preceding interactions to maintain coherent trajectories, but an LLM world model introduces its own fidelity uncertainty unless grounded against programmatically verified state. A continuously verified simulator provides that grounding and measures the gap that remains. Each layer’s uncertainty can be located and tested.
Sources
- Agent-Diff: Benchmarking LLM Agents on Enterprise API Tasks via Code Execution with State-Diff-Based Evaluation
- Simulate to Generalize: Scaling Stateful Supervision for API-calling Agents using LLM World Models
- The Sim-to-Real Gap of Foundation Model Agents: A Unified MDP Perspective
- Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
- Mind the Sim2Real Gap in User Simulation for Agentic Tasks


