A robot trained in simulation usually fails in the real world because the simulator's physics are slightly wrong: the friction is off, the object is heavier, the motor has backlash. One fix that works well is to let the policy watch its own recent interactions and infer the true physics on the fly. A sequence model reads the history of what the robot did and what happened, then outputs an estimate of the hidden parameters, with no gradient updates. Current versions of this idea look at a very short history: four episodes in one case and a few transitions in another. They also assume the physics stay fixed while the robot watches. Real physics do not stay fixed. Payloads change, pads wear, and surfaces get wet. This creates a context-window problem. A longer history gives more evidence about many hidden parameters, but once the physics change, older history is wrong.
We propose to train in-context system identification ("system identification" means estimating a system's physical parameters from observed behavior) on long, compressed interaction histories collected in simulation. The key change is that we randomize how the parameters change over time, not only their values. The model then has to learn from data how much of its past to trust. The bet is that this "drift randomization" produces an estimator that closes much of the remaining gap to an oracle that is given the true parameters. We expect it to beat every fixed-window estimator in both speed of re-identification and steady-state accuracy, and to transfer to hardware drifts it never saw in simulation.
Core Claim
Two papers motivate this proposal and also show its limits. Dynamics as Prompts (CAPTURE) treats robot interaction history as a prompt to a causal Transformer that predicts physical parameters. It is trained on simulated rollouts of a search procedure and reaches at least 70% zero-shot real success on object scooping, converging within 3 to 4 iterations. Its context, however, is capped at 4 iterations and its parameters are static. Can Context Bridge the Reality Gap? conditions a policy on a context vector estimated from recent transitions. On a physical Franka box-pushing task this raises success from 32% under plain domain randomization to 63%. The same paper reports three limits: its policies stay below the oracle, estimation degrades as the number of hidden parameters grows, and simple temporal average pooling fails where an LSTM succeeds.
We read these results as a context-window problem. A short window helps when physics change, because stale evidence leaves quickly. It hurts when there are many hidden parameters, because there is too little evidence. A fixed window cannot serve both cases. Our claim is that a model trained on simulated histories whose drift process is itself randomized will learn a history-dependent forgetting rule. That model should dominate the tradeoff curve that fixed windows trace out. The difference from prior work is specific. CAPTURE and the context-aware-policy paper randomize parameter values within an episode family and read a short window. We randomize the temporal process that generates parameters and read a long, compressed window.
Concretely, we sample a parameter trajectory $\theta_{1:K}$ over $K$ episodes from a drift process $D$. The process $D$ is drawn from a family $\mathcal{D}$ that includes constant parameters, step changes at random times, slow linear wear, and random walks with random volatility. The estimator $f$ is trained to predict the current parameters from the full history:
$$ \min_f \; \mathbb{E}_{D \sim \mathcal{D},\, \theta_{1:K} \sim D}\; \sum_{k=1}^{K} \big\| f(h_{1:k}) - \theta_k \big\|^2 . $$
Here $h_{1:k}$ is the sequence of states and actions from episodes 1 through $k$. Under a static process, the optimal $f$ averages over the whole history. Under a step process, it should discard everything before the change. Training across $\mathcal{D}$ therefore forces $f$ to detect which regime it is in.
Research Program
The estimator is a causal Transformer that receives a hierarchically compressed history. We borrow the idea from long-context language modeling. Scaling Instruction-Tuned LLMs to Million-Token Contexts builds long contexts out of chunk-level summaries and extends length in stages. ContextVLA compresses robot frame history into a single token early in the network, which cuts latency from 227 ms to 96 ms per step. We reuse both ideas, with one change. Each past episode is compressed by a learned attention pooling into a few summary tokens, rather than by averaging. We make this choice because the context-aware-policy paper found that average pooling smears out the contact discontinuities that carry information about the physics. The most recent episode is kept at full resolution. Training extends history length in stages, from 4 to 16 to 64 episodes, in the same way the language-model work extends its positional range in steps.
The program has three parts. First, we build drifting versions of three existing tasks in simulation: CAPTURE's scooping and air hockey, and the Franka pushing task from the context-aware-policy paper, which uses masses from 283 g to 824 g. Each gets programmable drift processes. Second, we train estimators and policies conditioned on their output. Third, we run a diagnostic borrowed from the "lost-in-the-middle" literature, where From Artificial Needles to Real Haystacks shows that models neglect evidence placed in the middle of a long input. We insert one highly informative episode at varying depths in the history, for example a collision that reveals the center of mass. We then check whether the estimator uses it when physics are static and ignores it after a change.
Baselines
The naive reference point is a context-agnostic domain-randomized policy. It is trained on the same simulated parameter ranges with no history input. On pushing, the context-aware-policy paper reports 32% real success for this baseline.
The strongest existing learned methods are two. The first is CAPTURE with its fixed 4-iteration window (Dynamics as Prompts), which reports at least 70% real scooping success. The second is the LSTM context estimator trained with policy loss (Can Context Bridge the Reality Gap?), which reports 63% real pushing success. Both will be retrained on our simulated data under two conditions, once with static parameters and once with drift-randomized parameters. Every method gets the same simulator, the same number of rollouts, and the same hyperparameter search budget, so that no comparison is decided by data access. We also include fixed sliding windows of 4, 16, and 64 episodes using our own architecture. These trace the speed-versus-accuracy curve the claim says we will dominate.
We add a classical recursive estimator: a particle filter over the simulator's parameters with a tuned forgetting rate. It is model-based and strong when the simulator's structure is correct.
The oracle receives the true current parameters. Two ablations isolate the key ingredients. One is our long-context model trained without drift randomization. The other is a drift-randomized model forced to use a 4-episode window. Beating a baseline means lower parameter error integrated over a drifting session and higher task success than every fixed window and the LSTM, with no loss in static-parameter accuracy relative to the best long-window baseline.
Why not just…?
Why not just use the LSTM estimator, which already compresses history recurrently? This is the most serious competitor. An LSTM trained on drift-randomized data might learn adaptive forgetting just as well. We test this directly by giving the LSTM identical drifting data and budget. If it matches our model, the contribution narrows to drift randomization itself, and the drift-randomized LSTM becomes the recommended method. We expect a Transformer with explicit long memory to win when hidden parameters are numerous. That is the regime where the context-aware-policy paper saw its short-horizon estimators degrade. This is a hypothesis, not a result.
Why not just tune a fixed window length per task? A tuned window is one point on the speed-versus-accuracy curve. Step-change sessions punish long windows, and static high-dimensional sessions punish short ones. Mixed sessions containing both are the decisive test. If one tuned window matches our model across mixed sessions, the claim fails.
Why not just run a particle filter with a forgetting factor? When the simulator is the right model, this may well win for low-dimensional parameters, and we will report that honestly. Our argument is about misspecification. The real gap includes effects the simulator does not model, and a filter that trusts the simulator's likelihood cannot absorb them. The sim-to-different-sim and hardware tests below are designed to show whether that distinction matters in practice.
Why not just randomize parameters more broadly, as in standard domain randomization? Both robotics papers report that broad randomization produces conservative "average" behavior. Its 32% pushing success is our naive floor.
Proposed Experiments
In simulation, we train in one physics configuration and test in a perturbed one. The test configuration adds unmodeled damping and actuator delay, which acts as a proxy for the real gap. The main measurements are three. Re-identification latency is the number of episodes needed to bring parameter error back within tolerance after a step change. Steady-state error is measured under static parameters, as a function of parameter dimensionality. Task success is measured for the conditioned policy.
The decisive generalization test holds out a drift family entirely. Models train on step and linear drift and are tested on oscillating drift. This probes whether learned forgetting transfers beyond the processes the simulator produced, which is the temporal version of the sim-to-real gap.
On hardware, we repeat the Franka pushing protocol with mass added mid-session and run air hockey across sessions with gradually changing surface friction. Success is compared against the reported 63% (policy-loss LSTM) and 32% (domain randomization) pushing figures. For scooping we compare against CAPTURE's reported at-least-70% success.
The claim is supported if three things hold. Our model must lie on or beyond the frontier of every fixed window. It must beat the drift-randomized LSTM in high-dimensional settings. And it must keep its advantage on held-out drift families. It is refuted if a tuned window, or the drift-randomized LSTM, matches it everywhere.
References
- Dynamics as Prompts: In-Context Learning for Sim-to-Real System Identifications
- Can context bridge the reality gap? Sim-to-real transfer of context-aware policies
- Scaling Instruction-tuned LLMs to Million-token Contexts via Hierarchical Synthetic Data Generation
- ContextVLA: Vision-Language-Action Model with Amortized Multi-Frame Context
- From Artificial Needles to Real Haystacks: Improving Retrieval Capabilities in LLMs by Finetuning on Synthetic Data