TL;DR
Continuous Context Management (CCM) is a new paradigm for long-horizon LLM agents that replaces the ever-growing interaction history with a compact, self-managed memory updated at every turn. By combining this approach with a novel training recipe—GRPO paired with privileged full-history distillation—the authors demonstrate that agents can maintain high task success while reducing cumulative input token usage by over 80%.
What Problem Does This Paper Address?
As LLM agents tackle increasingly complex, multi-step tasks (like shopping online or managing a Linux terminal), their "active prompt" grows longer with every interaction. This leads to several critical issues:
- Performance Degradation: LLMs often struggle to find relevant information in massive contexts (the "lost in the middle" effect).
- Resource Constraints: Long contexts consume significant GPU memory (KV cache), making it difficult to run large models on consumer-grade hardware.
- Cost: More tokens generally mean higher API bills.
While "periodic compaction" (summarizing history every few turns) exists, the context still balloons between compaction events. This paper explores the logical extreme: Continuous Context Management, where memory management becomes a core part of every single action step.
Methods
The authors propose a two-part solution involving a new inference flow and a specialized training objective.
1. CCM Inference Flow
In a standard agent, the prompt includes the entire transcript of previous turns. In CCM, the agent receives only the original task, a compact memory string from the previous turn, and the newest observation. The agent then outputs two things: an updated memory and the next environment action.
2. Training with Privileged Distillation
Training an agent to manage its own memory is hard because "success" is only measured at the end of a long episode. To provide better guidance, the authors use:
- GRPO (Group Relative Policy Optimization): An RL algorithm that uses episode-level rewards.
- Privileged Full-History Distillation: This is the "secret sauce." During training, a frozen "teacher" model is given the complete interaction history (privileged information). It scores the student's proposed actions. If the teacher—who sees everything—is more confident in a token than the student—who only sees the compact memory—the student is pushed to mimic that behavior.
Datasets
The researchers evaluated CCM across three diverse benchmarks:
- TerminalBench-2: 89 human-curated tasks involving realistic Linux terminal workflows.
- WebShop: A simulated e-commerce environment requiring navigation, product selection, and purchase.
- Endless Terminals: A large-scale benchmark (over 2,000 training tasks) for terminal agents managing files, logs, and databases.
Key Insights and Ideas
- Out-of-the-Box Capability: High-end frontier models like Kimi K3 can actually perform CCM reasonably well without any specialized training, though most models (like Claude 3.5 Sonnet) see a performance dip when forced to use compact memory.
- The "Aha" of Distillation: RL alone (GRPO) often fails to teach agents how to use memory effectively. The privileged teacher acts as a bridge, showing the student what information should have been in its memory to make the right choice.
- Memory vs. API Caching: Interestingly, while CCM uses far fewer tokens, it isn't always cheaper on platforms like Amazon Bedrock or Anthropic. This is because "prefix caching" rewards keeping a long, static history. CCM, by changing the memory string every turn, breaks this cache.
- Generalist Preservation: The distillation objective doesn't just help with the task; it also helps the model retain its general reasoning capabilities (like MMLU scores), which often degrade during narrow RL tuning.
Key Results
- Massive Token Savings: On TerminalBench-2, CCM reduced cumulative input tokens by 75% to 84% across different models.
- Performance Boost: On WebShop, the Qwen3-4B model using CCM + Distillation achieved an 86.72% success rate, actually outperforming a version of the same model trained on the full history (81.25%).
- Efficiency: For Qwen3-8B on WebShop, distillation improved success from ~12% (GRPO only) to over 77%.
Limitations and Future Work
- Observation Bottleneck: CCM manages history, but it doesn't currently compress the current observation. If a single terminal output is 50,000 characters, the prompt will still be huge.
- Economic Trade-offs: As noted, current API pricing models for "caching" can penalize the very memory efficiency CCM provides.
- Future Directions: The authors suggest exploring ways to compress the current observation and investigating how these agents behave over even longer horizons (thousands of turns) where full-history methods would be impossible.
For more details, you can find the full paper titled "Continuous Context Management" on arXiv (2609.35540v1).
Summary updated