Manuscript Offprint

arXiv:2610.25758

Remember Less, Adapt Longer: Bounded-State In-Context Reinforcement Learning with Recurrent Summary Memory

Jiawen Wang, Cheng Xue, Peng Zhang, Jochen Renz

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

In-context reinforcement learning (ICRL) enables agents to adapt to new tasks without parameter updates, relying on memory to retain what they learn from experience. For agents operating continually, existing approaches using memory trade off bounded cost against access to past experience. Approaches using growing memories, such as full-history attention and accumulating summaries, incur storage and per-decision costs that increase with task length. Fixed-size memories bound storage but restrict access: sliding windows discard older steps, while recurrent networks compress even recent interactions into a hidden state. We introduce Recurrent Summary Memory (RSM), a Transformer policy that attends exactly to a short working buffer of recent interactions and carries a fixed-capacity summary of earlier experience. When the buffer fills, RSM rewrites the summary from its previous contents and the buffer, then clears the buffer, so deployment memory and per-decision cost stay O(1)O(1) in task length. On long-running partially observable tasks, frozen RSM policies sustain their adapted performance for eight times the training horizon with about 1% of full-history memory, ending ahead of every evaluated baseline while growing memories deteriorate. When the task configuration changes mid-run, RSM re-adapts better than growing and recurrent memories. Clearing the summary or blocking the policy's access to it removes its benefit, while swapping in another task's summary steers behaviour towards that task. Together, these results show that our fixed-capacity summary can sustain in-context adaptation far beyond the training horizon.

1 INTRODUCTION

An agent placed in an unfamiliar environment often cannot directly observe everything it needs to act, so it must use past experience to inform its decisions and adapt to the environment (Kaelbling et al., 1998). In Dark Key-to-Door (Laskin et al., 2023), for example, an agent that searches a dark room for a hidden key and then a door should reuse the key's location on every later attempt; in a maze with unfamiliar controls, an inferred mapping from actions to movements should support navigation throughout the task. In-context reinforcement learning (ICRL) trains policies to adapt in this way: a single policy is trained across tasks to condition its decisions on its history of observations, actions, and rewards, enabling adaptation without test-time parameter updates (Laskin et al., 2023; Lee et al., 2023; Grigsby et al., 2024). Because its parameters remain fixed, memory must carry the task knowledge acquired during deployment (Duan et al., 2016; Wang et al., 2016). For an agent that keeps operating, continued adaptation therefore depends on preserving useful discoveries.

Existing memory architectures trade off bounded cost against access to experience. Full-history Transformers (Parisotto et al., 2020; Grigsby et al., 2024) let a policy revisit individual records, but their key/value caches and per-decision attention costs grow with task duration. Sliding windows bound these costs by discarding older records, even when their information remains useful (Xiao et al., 2024). Recurrent networks such as GRUs (Cho et al., 2014) maintain a fixed-size hidden state and provide strong baselines under partial observability, but compress even recent interactions (Heess et al., 2015; Ni et al., 2022; Morad et al., 2023). Summary memory offers a way to separate immediate access from longer-term retention: recent records provide direct context, while a compact representation carries earlier experience (Rae et al., 2020; Ge et al., 2024). Segment-level Transformers implement this separation with local attention and representations carried between segments (Dai et al., 2019; Hutchins et al., 2022): Recurrent Memory Transformers (RMTs) carry a fixed bank of memory tokens (Bulatov et al., 2022), whereas Memo appends one summary block per segment, so its state still grows (Gupta et al., 2025).

A fixed-capacity summary eliminates storage growth, but bounded storage alone does not guarantee sustained adaptation. Once a segment is discarded, its useful evidence must survive not only the next summary, but every subsequent rewrite until it is needed. Re-exploring the room may recover a forgotten key location, but not a cue presented only once (Ni et al., 2023). Conversely, when the hidden task changes, retaining obsolete evidence can obstruct adaptation. The summary must therefore learn both to preserve relevant information and to revise it. These demands grow beyond the training horizon, where memory undergoes more rewrites than in training. Success on finite training tasks need not imply reliable memory during continued operation; indeed, finite and continuing memory tasks can reverse the relative performance of recurrent and attention-based agents (Pleines et al., 2025). We therefore ask: Can a Transformer policy sustain useful in-context adaptation beyond its local context and training horizon under a fixed deployment memory budget?

We address this question with Recurrent Summary Memory (RSM), a Transformer policy with a recurrent-memory architecture. RSM combines exact attention over a short-term working buffer of the current segment's interactions with a fixed-capacity long-term summary. Here, exact means that each decision attends directly to the cached representation of every record in the buffer, not that the whole history is kept. At each segment boundary, it writes a replacement summary from the previous summary and buffered steps, then clears the buffer, so only the new summary carries earlier experience into the next segment. What the summary retains is learned only through the actor-critic losses, not set by token-retention rules (StreamingLLM; Xiao et al., 2024) or auxiliary reconstruction losses (Compressive Transformers; Rae et al., 2020). With fixed capacities, RSM's deployment state and per-decision computation are O(1)O(1) in task length: in our experiments it holds 249.9 KB per agent, whereas a full-history cache of the same backbone grows by 6 KB per step, to about 5 GB after a day of 10 Hz control. Such bounds matter for robots with fixed onboard memory, game agents acting over thousands of steps, and services running many agents in parallel.

To test whether this bounded memory sustains adaptation, we evaluate RSM on four partially observable benchmarks: Dark Key-to-Door (location reuse; Laskin et al., 2023), CountRecall (evidence accumulation; Morad et al., 2023), MazeRunner (navigation with unknown action mappings; Grigsby et al., 2024), and the passive T-Maze (one-time-cue recall; Ni et al., 2023). We compare against a full-history Transformer, a GRU, accumulating-summary Memo, and a state-matched sliding window, trained with the same learner, inputs, losses, and interaction budget. On these benchmarks, a fixed-capacity summary sustains in-context adaptation far beyond the training horizon, answering our question affirmatively. Specifically, our contributions are:

• Bounded summary memory for online in-context RL. We specify and evaluate RSM, combining an exact segment-local working buffer with a fixed-capacity summary produced by learned write queries and a projected overwrite. RSM is trained with AMAGO's (Grigsby et al., 2024) off-policy actor–critic losses through every carried write. Its deployment state and per-decision cost remain O(1)O(1) in task length (Section 3).

• Sustained adaptation beyond the training horizon. RSM remains competitive at the training horizon; frozen RSM policies maintain adapted performance over eight times that horizon and re-adapt better than growing and recurrent memories when the hidden task changes, whereas growing memories deteriorate (Section 4.2).

• Evidence that decisions depend on summary content. Clearing the summary, transplanting another task’s summary into it, and blocking the policy’s access to it show that the policy uses its content; linear probes recover hidden task variables; and write-rule ablations show greater stability with overwriting than with additive updates (Sections 4.3–4.4).

References (68)