Tracing Sim-to-Real Policy Degradation to the Specific Environment Contract Assumptions That Broke

Diagnose sim-to-real failures by naming the broken simulator assumption.

· 8 min read
Cover illustration for “Tracing Sim-to-Real Policy Degradation to the Specific Environment Contract Assumptions That Broke”
RL Environment Design · November 27, 2026 · 8 min read · 1,885 words

To use an API in a reinforcement learning environment, treat tool calls as actions and API responses as observations, with a stateful simulator representing the service during training. Check its behavior against the live API and test failures on purpose before deployment. Sim-to-real policy degradation is best diagnosed as a broken environment contract.

Why sim-to-real degradation is a contract problem, not a gap problem

The word “gap” describes distance but does not identify a cause. A broken contract identifies a promise that failed. Every simulator makes promises about the environment a policy will encounter, whether engineers document those promises or leave them implicit in code. A policy learns against those assumptions, so its deployment performance depends on how faithfully they describe the real environment.

This changes the unit of diagnosis. Instead of asking why simulation performance was better, engineers can ask which assumption stopped holding and how heavily the policy relied on it. Pan et al.’s preprint, accepted in December 2025, describes degradation arising from “unmodeled dynamics and environmental disturbances.” That language points to modeling omissions rather than an unexplained difference between two worlds. If degradation has identifiable causes, it can be investigated through a repeatable diagnostic discipline.

A working taxonomy of the environment contract assumptions that break

Observation fidelity contracts set the rules for what the agent perceives. They promise that the simulator’s observations represent what the deployment environment produces, including sensor noise, visual appearance, and data formats. For example, a simulator may assume Gaussian sensor noise with parameter Y. If the observations at deployment fall outside that assumption, perception can fail before the policy’s choice of action matters.

Transition dynamics contracts set the rules for what an action causes. They encode relationships such as friction, actuator response, and aerodynamic drag. A quadrotor simulator that omits payload changes offers a transition model that may no longer predict the aircraft’s movement after its payload changes. Pan et al. study this kind of mismatch through residual dynamics learning.

State management contracts set the rules for what the environment remembers. A write at one step must affect the later reads that should observe it. For example, a POST to /records followed by a GET /records should return the new record. A stateless simulator returning cached responses teaches the policy a different kind of world, where calls are independent.

Interface and timing contracts govern how interactions occur. They cover latency, rate limits, error codes, retry semantics, and response schemas. For example, a simulator that always returns well-formed JSON does not exercise the response-handling path needed when an API returns a malformed payload. The boundary with observation fidelity is practical. Observation fidelity concerns what the agent perceives, while the interface contract concerns how the service delivers or fails to deliver it.

How these contract breaks manifest differently in physical robotics versus software agents

In robotics, a transition-contract break can appear as physical instability. A quadrotor may fail to hold position because wind or payload changes invalidate the dynamics represented during training. Pan et al. report reductions in hovering error of up to 81% after correcting for these disturbances in their December 2025 preprint. The visible symptom is motion that departs from expectation. The diagnostic target is the modeled relationship between control input and physical response.

In software agents, a state-contract break can appear as a logical failure. A simulator that does not apply a prior write may return stale data from a list endpoint, while deployment exposes the policy to accumulating state. An interface-contract break can instead leave an agent unable to handle a timeout that training never exercised. The visible symptom is an incorrect or interrupted tool sequence. The diagnostic target is the modeled relationship between API calls, shared state, and returned results.

Xu et al.’s Real–Sim–Real framework uses an information-theoretic cost function that accounts for discrepancies between simulation and the physical system. For API agents, this means comparing tool-call sequences and the state they produce, beyond checking response payloads on their own. Green CI is insufficient if mocks bypass actual dispatch, retries, state accumulation, or fallback routing. A policy can learn correctly against an inaccurate environment, so deployment failure alone does not establish a defect in its reasoning.

Why standard mitigations treat symptoms rather than surfacing which contracts broke

Domain randomization helps because it trains policies under a range of conditions. Pan et al. state that it “cannot exhaustively anticipate all possible real-world conditions.” Xu et al. also describe its lack of real-world feedback as an open-loop limitation. Widening a distribution can improve robustness without revealing which assumption failed outside it.

Real2Sim2Real pipelines use real data for simulator calibration so the modeled behavior more closely matches what is observed. That improvement has costs in data collection and offline retraining. Online adaptation deals with a different constraint because it responds during deployment. Pan et al. report adaptation within 5 seconds of encountering a new disturbance. This is valuable recovery, but recovery after an encounter is not evidence that the failed assumption was surfaced before deployment.

Low-fidelity sandbox stubs also have a legitimate role. Canned responses let teams test how expected responses are handled without a live service, while manual environment hardening adds edge cases that are already known. Their coverage depends on what engineers explicitly construct. A static response cannot represent intervening writes unless the test adds a state model, and manually added cases do not establish continuing agreement with an evolving API. A mock can return an error deliberately, but that alone does not test the error within a realistic state sequence.

These techniques need not be discarded or treated as inherently opaque. They can support contract diagnostics when paired with explicit assertions and measurements. By themselves, however, improved policy performance or simulator fit does not identify the clause that failed. Compensation and diagnosis answer different questions. Preventing recurrence requires tracing the assumption as well as improving the outcome.

A systematic framework for naming, categorizing, and surfacing broken contracts before deployment

Diagram: Five Steps to Contract-Aware RL Deployment. Visualizes: Show a five-step sequential flow representing the systematic framework for surfacing broken environment contracts before deployment.

The first step is to enumerate testable contracts when building the simulator. Each assertion belongs to observation fidelity, transition dynamics, state management, or interface and timing. A robotics assertion might state that friction at deployment falls within the sampled range. An API assertion might specify that creating a record makes it visible to a later list request.

The second step is continuous comparison with the real environment. For software agents, this means running identical call sequences against the simulator and live API, then publishing agreement rates. For robotics, it means comparing modeled interactions with the corresponding physical system behavior. Divergence should trigger a named violation and block deployment when agreement falls below the chosen threshold. One-time validation is insufficient because API behavior and physical operating conditions can change.

The third step is to measure policy dependence on each clause. Engineers deliberately violate one assumption at a time and measure the resulting performance loss. A robotic policy might be exposed to sensor noise beyond its training distribution, while an API policy might encounter inconsistent state after a write. This ranks assumptions by consequence. Han and Feng’s formulation links risk to uncertainty about environment context, providing a template for this dependency analysis.

The fourth step is to make contract violations first-class test cases. Robotic tests can inject payload changes, unfamiliar terrain, and sensor noise outside the trained distribution. Software-agent tests can inject latency, 429s, 503s, malformed responses, out-of-order webhooks, and state inconsistency. Each test should name the clause it challenges and the expected policy behavior. Reproducibility separates a planned stress test from an unexplained failure.

The fifth step is to version the contracts with the policy. When the simulator is updated or deployment changes, the record should state which assumptions changed, whether they concern a physical dynamics range or how an API responds. Engineers can then check a policy against the changed clauses before release. The version history also narrows later investigations. It provides a specific change to examine rather than forcing every regression investigation to start with the whole system.

What stateful, continuously verified simulators make possible that static mocks and randomization cannot

Contract-level diagnosis requires an environment that represents the dependencies under test. For API training, statefulness is therefore fundamental. A simulator must apply writes to shared world-state so later reads can reflect their cumulative effects. Static responses may approximate individual calls, but they cannot establish this sequence-level agreement on their own. Randomization does not repair that omission because varying outputs is different from maintaining a coherent world.

Continuous verification adds evidence that the modeled world still matches the service. A simulator verified only at build time can fall behind changes to schemas, edge-input behavior, or rate-limit policies. Agreement measurements make those changes visible. Robotics has the same need to refine models against real-world observations to account for unmodeled effects. Verification establishes the current scope of fidelity.

Tests must reproduce a particular violation within a known state sequence so engineers can compare policy responses across versions. A static mock can emit an error, but it cannot by itself reproduce the resulting evolution of shared state. RL training also requires controlled state across episodes and support for thousands of rollouts. Named, pre-seeded scenarios let engineers rely less on empty sandboxes and the limited states they build by hand.

Rystic is one option in this category, a stateful API simulator platform for software-agent RL environments in which each write is visible to later reads and simulators are continuously verified against live APIs including those for workplace messaging, payment processing, and prediction markets. It publishes fidelity scores from verification runs each day and has named pre-seeded scenarios that are chosen at boot.

How can you use an API in an RL environment with a contract-aware workflow?

Consider a team training a payment agent. Before writing agent code, the team audits the proposed simulator for shared state, live-API verification, and deterministic fault injection. A missing capability becomes an explicit risk to accept. The training environment is judged by the interactions it represents. This changes simulator selection from a convenience decision into a contract review.

During CI design, the team turns those contracts into test classes. Observation tests check the data the agent receives, while transition tests check whether tool calls have the effects the model says they should. State-sequence tests check writes and the reads that follow them, and interface tests add timeouts, malformed responses, and rate-limit errors. These tests run in the simulator on every merge without live credentials or production data. A failure names the clause that was violated as well as reporting that the payment agent regressed.

Before deployment, the team reviews the simulator’s published fidelity score and contract-version changelog. If any clause has changed since training, checking the policy again against the new contract is a release gate. A policy that succeeds in the original environment has not yet demonstrated that it can handle revised service behavior. The review connects evidence from API verification to the assumptions used during training.

If the payment agent later degrades, triage begins with the contract history and fault-injection results. The team investigates which clause failed first and whether earlier tests exposed the policy’s dependence on it. That narrows the search to a named hypothesis. Without this discipline, a regression invites broad exploratory debugging. With it, sim-to-real degradation becomes a managed engineering risk that teams can observe, name, and mitigate systematically.

Sources

  1. IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED DECEMBER, 2025
  2. Transferable Reinforcement Learning via Probabilistic Latent Embeddings and Dynamic Policy Adaptation for Sim-to-Real Deployment
  3. An Real-Sim-Real (RSR) Loop Framework for Generalizable Robotic Policy Transfer

More in RL Environment Design