ACM: Agentic Context Management – Enabling LLM Agents to Autonomously Manage Their Context for Long-Horizon Tasks

ACM: Agentic Context Management for Long Horizon Tasks

Xiaochuan Li, Ryan Ming, Meng Chu, Shuai Shao, Rong Jin, Chenyan Xiong
Summary
Problem
Method
Results
Takeaways
Abstract

ACM (Agentic Context Management) is a framework that enables LLM agents to autonomously decide when to compress their context using two purpose-built tools (manage_context and query_memory), achieving lossless compression by offloading discarded content to external memory. A teacher-student post-training pipeline with dual constraints internalizes context management capabilities, yielding a 27% relative improvement on BrowseComp-Plus and an 8% improvement on SWE-Bench Verified over ReAct baselines on a 9B model.

TL;DR

Agentic tasks produce long, noisy trajectories that exceed context windows, even with million-token support. Prior compression methods are lossy and triggered by rigid heuristics. ACM introduces two memory tools (manage_context and query_memory) that allow the agent to autonomously decide when to compress and retrieve context losslessly. A dual-constraint teacher-student training pipeline internalizes this ability, achieving a 27% relative improvement on BrowseComp-Plus and an 8% improvement on SWE-Bench Verified over ReAct baselines on a 9B model.

Background Positioning: This work is a practical, post-training-focused contribution that bridges the gap between heuristic context compression (e.g., ReSum, ACON) and full RL-based memory management (e.g., Mem1, SUPO). It provides a scalable, open-source data generation pipeline and demonstrates that agent-initiated, lossless context management is both learnable and highly effective.

Problem & Motivation

Why is context management hard for agents?

Long-horizon agentic tasks—multi-step search, complex code editing—generate verbose histories: failed attempts, redundant observations, lengthy tool outputs. Even with a 128K context window, the signal-to-noise ratio degrades, and the model's reasoning quality suffers. The core challenge is when and how to compress without losing critical information.

Prior Work Limitations

  • Heuristic compression (ReSum, ACON, DeepSeek-V3.2): compression is triggered by fixed token thresholds, external to the agent's reasoning. This leads to premature or unnecessary compression, and the compressed content is one-way—raw messages are discarded.
  • Memory-augmented approaches (Mem1, ACE, AgentFold): maintain external memory, but either require full RL training from scratch, do not work within a single episode, or lack open-source data pipelines.
  • Key gap: No existing method combines lossless compression (raw content preserved for later retrieval) with agent-initiated timing (the agent decides when to compress based on its own reasoning state).

Research Intuition

The authors draw inspiration from human cognition: we keep immediately relevant information in working memory and offload less immediate details to external storage, retrieving them on demand. By giving the agent two simple tools—manage_context (compress and save) and query_memory (retrieve)—the agent can autonomously mimic this behavior, expanding or contracting its effective context as needed.

Methodology

ACM Framework

ACM introduces two tools:

  • manage_context: Compresses all messages since the last compression boundary into a summary (8K tokens or less). The raw messages are preserved on disk, indexed by a unique summary_id. The summary is returned as a tool result, keeping the working context compact.
  • query_memory: Takes a summary_id and a natural language query. The system retrieves the raw messages from that summary and uses an LLM to extract relevant information, returning it to the agent.

Crucially, compression is agent-initiated—the model itself decides when to call manage_context, based on its reasoning state. This is in contrast to the "Summary Agent" paradigm where an external monitor triggers compression at a fixed token threshold.

Overview of our ACM Framework. ReAct eventually hits the context limit, while the Summary Agent is forced to compress whenever usage exceeds a predefined threshold. The ACM agent autonomously decides when to manage its context losslessly.

Training Pipeline: Dual-Constraint Teacher-Student

The authors found that even frontier models (e.g., GPT-5.5) rarely invoke context management autonomously. To internalize the skill, they design a post-training pipeline:

  1. Student Rollout: The student (Qwen3.5-9B) completes the task twice: once without context management tools (H⁻) and once with them (H⁺).
  2. Teacher Annotation: A stronger teacher (Qwen3.5-397B-A17B) reviews both trajectories against the reference answer:
    • Injection on H⁻: The teacher identifies turns where context management would be beneficial (e.g., when the student is stuck in a loop) and injects a manage_context or query_memory action.
    • Refinement on H⁺: The teacher identifies turns where the student called context management prematurely (e.g., when it should have searched further or committed to an answer) and replaces the call with a more productive action.
  3. Training: The student is fine-tuned via on-policy distillation against the teacher's soft next-token distributions, learning both when to invoke and when to refrain from context management.

Overview of the dual-constraint training data generation pipeline. A student agent completes task rollouts both with and without context management tools. A teacher model reviews each trajectory against the reference answer and either injects ACM action or replaces non-ACM actions.

Experiments & Results

Main Results

MethodBrowseComp-Plus (Pass@1)DeepSearchQA (Pass@1)SWE-Bench Verified (Pass@1)
ReAct (Qwen3.5-9B)0.5700.3670.489
ReSum (Qwen3.5-9B)0.6080.3710.475
ACON (Qwen3.5-9B)0.6140.3800.480
ACM Base (Qwen3.5-9B)0.6350.4050.508
ACM Post-Trained (Qwen3.5-9B)0.7270.4250.530
Gemini3-Flash (frontier)0.7330.6190.732

Table: Main results on three benchmarks. ACM-Post-Trained achieves a 27% relative gain on BrowseComp-Plus and nearly matches frontier models 40× larger, while using fewer peak tokens.

Key observations:

  • 27% relative improvement on BrowseComp-Plus over ReAct.
  • Peak token usage drops ~20% compared to summary-based baselines, reducing KV-cache overhead.
  • Tool call frequency increases significantly, enabling deeper exploration.

Context Growth Dynamics

Input token count over interaction turns for ACM and ReAct agents. Gray curves show individual ACM trajectories; red dots mark context management calls. Yellow and blue curves denote the population average for ReAct and ACM, respectively.

The sawtooth pattern in ACM trajectories shows that compression is triggered proactively, well before the context limit. This allows the agent to sustain much longer exploration (up to 222K raw tokens processed while keeping the working window under 128K).

Pass@K Consistency

ACM significantly improves Pass4 (all 4 trials correct), indicating that a clean context leads to more consistent solutions. The gap between Pass@1 and Pass4 narrows, suggesting that context management not only expands the set of solvable problems but also makes correct solutions more reliable.

Critical Analysis & Conclusion

Summary

ACM introduces a paradigm shift in context management: agent-initiated, lossless compression. The dual-constraint training pipeline is a practical, scalable method to internalize this ability, and the open-source release of data generation code enables broader adoption.

Strengths

  • Lossless: Unlike summary-based methods, raw content is always retrievable, enabling precise information recovery.
  • Agent-initiated: Timing aligns with the agent's reasoning state, not a fixed heuristic.
  • Scalable training: The teacher-student pipeline can be applied to any existing model checkpoints without full RL.
  • Proven gains: Significant improvements across search and coding tasks, with reduced peak token usage.

Limitations

  1. Requires strong base model: Context management is only meaningful when the agent can sustain long, coherent rollouts. 4B models collapse to 2-turn trajectories and never benefit from compression.
  2. Re-implemented baselines: Prior methods (ReSum, ACON, ACE) were re-implemented to match the evaluation setup; minor implementation differences may exist.

Future Work & Open Questions

  • Can ACM be extended to multi-modal agents (e.g., vision-language navigation, robotic control) where context includes non-textual observations?
  • How does ACM interact with long-context models that support 1M+ tokens? Is compression still beneficial beyond a certain window size?
  • The dual-constraint pipeline could be generalized to other agentic skills beyond context management, such as task decomposition or tool selection.

Final Takeaway

ACM shows that the key to effective long-horizon agentic reasoning is not just larger context windows, but smarter, agent-driven context management. By giving the agent the ability to compress and retrieve losslessly, and by training it to use this ability appropriately, we can unlock significantly more effective exploration and more consistent solutions.

Find Similar Papers

Try Our Examples

  • Find recent papers that address the problem of context overflow in LLM agents for long-horizon tasks, especially those using agent-initiated compression or memory management.
  • Which paper first introduced the concept of using short-term and long-term memory separation for LLM agents, and how does ACM build upon this idea?
  • What research has applied agentic context management or similar memory-augmented approaches to multi-modal agent tasks, such as vision-language navigation or robotic control?
Contents
ACM: Agentic Context Management – Enabling LLM Agents to Autonomously Manage Their Context for Long-Horizon Tasks
1. TL;DR
2. Problem & Motivation
2.1. Why is context management hard for agents?
2.2. Prior Work Limitations
2.3. Research Intuition
3. Methodology
3.1. ACM Framework
3.2. Training Pipeline: Dual-Constraint Teacher-Student
4. Experiments & Results
4.1. Main Results
4.2. Context Growth Dynamics
4.3. Pass@K Consistency
5. Critical Analysis & Conclusion
5.1. Summary
5.2. Strengths
5.3. Limitations
5.4. Future Work & Open Questions
5.5. Final Takeaway