TL;DR
When you feed an LLM its past attempts alongside numeric reward scores, it gets better at the task—a phenomenon widely celebrated as "In-Context Reinforcement Learning" (ICRL). However, this paper reveals a plot twist: the model barely cares about the rewards! Even if you randomize, flip, or completely delete the reward scores, the LLM improves just as much, proving that what looks like reinforcement learning at inference time is actually just classic pattern-matching imitation in disguise.
What Problem Does This Paper Address?
Modern AI agents often improve on the fly without updating a single weight: they try a task, get a score, drop that (attempt, reward) pair into their context window, and try again. Because this setup borrows the vocabulary of Reinforcement Learning (RL)—trajectories, rewards, exploration—researchers frequently treat it as genuine inference-time RL.
Yet, we already know from standard In-Context Learning (ICL)—where you give an LLM a few input-output examples—that models are notoriously indifferent to whether the labels are actually true; they care far more about the formatting and overall distribution of the prompt. This creates a fundamental mystery: when an LLM improves from past experiences in its prompt, is it genuinely optimizing for higher rewards like an RL agent, or is it just doing superficial ICL pattern matching?
Methods
To isolate the mechanics at play, the authors strip away fancy memory modules or reflection steps and study Direct ICRL: feeding a frozen LLM raw text concatenations of past trajectories and scalar rewards (Trajectory: [τ] \n Reward: [r]). Across six open-source and proprietary LLMs (spanning Qwen, Llama, Gemini, and GPT families), they run three surgical interventions:
- Reward Perturbations: Keeping the past trajectories identical, they replace true rewards with flipped rewards (making failures look like triumphs and vice versa), random rewards, or delete the reward field entirely.
- Replay Tracking: Using a leave-one-out log-probability metric ($\Delta\text{LOO}$) and Abstract Syntax Tree (AST) matching over 500 generations, they measure how strongly showing a trajectory—and tweaking its reward or position—causes the LLM to regenerate it.
- Trajectory Perturbations: They corrupt the logical meaning of trajectories while preserving their surface look—shuffling lines of code or action sequences, splicing different tasks together, or injecting syntax errors—to see what actually fuels the performance boost.
Datasets
The authors evaluate Direct ICRL across three existing benchmarks (no new datasets are introduced, as no model training occurs):
- HumanEval+ & MBPP+: Python coding benchmarks treated as single-step decision tasks, where the trajectory is the generated program and the reward is the unit-test pass rate.
- ScienceWorld: A text-based simulation of an elementary science curriculum requiring multi-step sequential actions (e.g.,
move to kitchen,focus on metal fork), testing credit assignment across sub-goals.
Key Insights and Ideas
- Rewards are read, but mostly ignored: LLMs do understand the reward numbers—giving a trajectory a high score nudges the model toward repeating it—but this RL-aligned nudge is dwarfed by the sheer gravitational pull of simply having the text in the context window.
- Showing a failure breeds more failures: In standard RL, low rewards push an agent away from bad actions. In Direct ICRL, merely exposing an LLM to a failed trajectory makes it much more likely to repeat that failure—even if you label it with a zero reward or explicitly command the model not to repeat it!
- Vibes over logic: You can scramble the order of actions in a multi-step science experiment—destroying causal logic—or inject syntax-breaking tokens into code, and the LLM still gets the exact same performance boost. It doesn't trace step-by-step causal chains; it just needs task-relevant vocabulary and surface structure to prime its existing priors.
Key Results
The numbers paint a stark picture against the "inference-time RL" narrative:
- Perturbed rewards still win: Across all three benchmarks, flipping, randomizing, or omitting rewards entirely produces improvement curves nearly identical to using true rewards—and all easily beat a zero-context random sampling baseline.
- Tiny reward sensitivity: In fixed-memory tests across 360 model-task pairs, only 3.9% (14 pairs) showed true reward-sensitive improvement, while 36.9% improved regardless of reward accuracy.
- Imitation overpowers reward by ~7x: Simply placing a low-reward trajectory in memory more than doubles overall memory replay (from 16.3% to 34.3%). Attaching or flipping its reward shifts generation log-probabilities ($\Delta\text{LOO}$) by at most 0.058—roughly 14% of the 0.416 boost caused by the trajectory's mere presence.
- Recency beats reward: Moving a trajectory to the very end of the prompt spikes its target replay rate from 3.0% to 13.2%—nearly 10x larger than the biggest shift achieved by changing its reward (1.4 percentage points).
- Corrupted trajectories work fine: Shuffling action steps in ScienceWorld yields a score of -38.588, actually edging out unperturbed ICRL history (-42.238), whereas swapping in trajectories from a different task tanks performance (0.245 down to 0.122 on MBPP).
Limitations and Future Work
The authors note that their findings apply strictly to Direct ICRL using raw (trajectory, reward) pairs under standard prompts. They exclude abstraction-based agents (like Reflexion, which summarizes mistakes into natural-language advice—and which their own tests show avoids blind trajectory replay) as well as specialized models explicitly trained for ICRL (like Decision Transformers). Furthermore, their setups don't fully test adversarial regimes where rewards directly contradict an LLM's pretrained knowledge. Moving forward, the authors suggest rethinking agent memory design: instead of relying on failed trajectories to spark RL-style exploration, builders should focus on ICL principles like curating clean input distributions and stabilizing text-based reflection methods.
Summary updated