Learning Agent-Compatible Context Management for Long-Horizon Tasks
LLM agents increasingly face long-horizon tasks such as web search and deep research in real-world applications, where accumulated context can cause long-context degradation and reasoning failures. Prior work mitigates this through context management with agent-side context control or fixed strategies such as summarization, which require training the agent itself for adaptation — making it impractical for closed-source agents and ignoring that different agents may require different strategies. We introduce Adaptive Context Management (Ada- CoM), which trains an external LLM to manage the context of a frozen agent through flexible modification actions and end-to-end reinforcement learning. Across diverse agents on web search and deep research benchmarks, Ada- CoM substantially improves performance by preserving task constraints and progress while pruning stale content. The learned strategies reveal a Fidelity–Reliability Trade-off: agents with higher vanilla ReAct performance benefit from higher-fidelity context preservation, whereas lower-performing agents require more aggressive compression to stay within a reliable reasoning regime.
Introduction. With advances in semantic understanding, tool use, and interactive decision making, general-purpose LLM agent applications such as OpenClaw and Hermes Agent have emerged (Steinberger and contributors, 2025; Nous Research, 2025). Such applications often involve long-horizon reasoning, where tasks such as answering multi-constraint search queries (Wei et al., 2025; Li et al., 2025) or producing deep research reports (Du et al., 2025; Wang et al., 2025) require many interdependent steps over a growing context. A central bottleneck for LLMs in such long-horizon tasks is longcontext degradation. As tool results and intermediate reasoning accumulate, stale or irrelevant content can obscure salient evidence, amplify positional bias, and make subsequent decisions less reliable (Xiao et al., 2024; Liu et al., 2024; Shi et al., 2023). Prior work addresses this issue through context management, but typically places the burden of managing context on the agent itself.
Discussion / Conclusion. We introduced AdaCoM, an adaptive context management framework that trains an external manager to manage an agent’s running context while keeping the underlying agent frozen. With a flexible modification action space and RL training, Ada- CoM learns agent-compatible context management strategies. Experiments show that AdaCoM consistently improves diverse agents and can transfer to unseen agents with similar baseline capability. Our analysis further reveals a Fidelity–Reliability Trade-off: effective context management should preserve as much task-relevant information as possible while keeping the agent within a context regime where its reasoning remains reliable.
Lines of inquiry this paper opens 24
Research framings built by reading the notes related to this paper — the questions it feeds into.
What causes misalignment between agent reasoning and actual agent behavior? Can agents actually improve through deployment and real-world feedback? How should agent memory be structured to optimize context efficiency and knowledge reuse?- Can the same compress-then-act pattern work for agent state memory?
- Can external managers optimize context better than the model itself?
- Why is digital context more volatile than conventional software context?
- Why do weaker agents need more aggressive context compression than stronger ones?
- How does external context control compare to agents managing their own state internally?
- Should optimal context budgets scale with agent competence or task complexity?
- Can context management policies transfer across agents of similar capability levels?
- Can externalizing bookkeeping to a stateful harness replace internalized memory control?
- How do memory hygiene and context efficiency trade off in deployed agents?
- Does recurrent memory or gist compression work better for ultra-long context?
- How does reducing activation precision further extend context length?
- Can fixed-size latent states losslessly store arbitrary input context?
- What components of agent scaffolding most impact domain-specific output quality?
- Why does externalized state beat parameter scaling for agent reliability?
- How does externalizing reasoning into harness artifacts improve agent reliability?