The "Latency Wall" in LLM Agents
As Large Language Model (LLM) agents tackle increasingly complex, multi-step tasks—such as software engineering or scientific discovery—their interaction histories grow massive. While modern LLMs can technically process millions of tokens, doing so in production environments is prohibitively slow.
The primary bottleneck lies not in the prefilling stage (reading the prompt), but in the decoding stage. As the interaction history grows, the Key-Value (KV) cache expands, rapidly saturating GPU memory bandwidth. Every new token generated requires fetching this massive cache from memory. While periodic summarization can reduce this context size, the act of summarizing traditionally happens sequentially, introducing its own latency overhead. Consequently, agents hit a "latency wall": they must either retain full history and operate at a snail's pace, or rely on shortcuts (like sliding windows or basic RAG) and risk losing the "big picture" of the task.
Introducing CoMem: Decoupled Context Management
To overcome this bottleneck, researchers introduce CoMem, a novel framework that decouples memory management from the primary agent reasoning workflow, enabling both processes to execute in parallel. CoMem splits the agent architecture into two specialized components:
- The Memory Model ($f$): A lightweight, dedicated model (e.g., Qwen-4B) tasked with compressing long-term history into a concise summary.
- The Agent Model ($\pi$): A larger, highly capable reasoning model (e.g., GLM-355B) that makes decisions based on the memory model's summary combined with a small buffer of recent, raw interactions.
Key Innovations
CoMem relies on two primary mechanisms to ensure this decoupled architecture is both fast and accurate:
- $k$-step-off Asynchronous Pipeline: Instead of forcing the agent to wait for a new summary at every step, the memory model runs in the background, lagging $k$ steps behind the agent. This asynchronous design effectively "masks" the summarization latency. The agent remains productive by utilizing the most recently available summary alongside the latest $k$ steps of raw history, ensuring no compute time is wasted idling.
- Reward-Driven Alignment (GRPO): A summary does not need to be a perfect prose recap; it only needs to trigger the correct "internal belief state" in the agent model. Using Group Relative Policy Optimization (GRPO), the memory model is trained for action consistency rather than human readability. It receives a reward if the agent's decision based on the summary matches the decision it would have made using the full raw history. This functional equivalence allows the memory model to aggressively discard irrelevant noise (like raw file contents or stack traces) while preserving sufficient statistics for the task.
Experimental Setup
The researchers evaluated CoMem across several benchmarks:
- SWE-Bench-Verified: A human-validated subset of software engineering tasks requiring agents to resolve real-world GitHub issues.
- BrowseComp-EN: A deep research benchmark involving multi-step information retrieval across the open web.
- R2E-Gym-Lite: Utilized to generate the reference trajectories required for the Reinforcement Learning training phase.
Key Results: Speed, Performance, and Scaling
Theoretical analysis and empirical results demonstrate that CoMem offers a superior efficiency-effectiveness trade-off compared to coupled architectures.
- Significant Latency Reductions: CoMem provides 1.4x to 2.08x end-to-end speedups compared to vanilla long-context solutions. Because CoMem bounds the context length, it prevents the "latency explosion" typically seen in standard models. In high-concurrency scenarios (e.g., batch size 64), it achieved a remarkable 4.95x peak per-step speedup.
- Maintained or Improved Performance: On SWE-Bench-Verified, CoMem (using a DeepSWE backbone) achieved a 41.0% resolve rate, slightly outperforming the full-context baseline (40.4%). This indicates that reward-driven summarization acts as an effective noise filter, improving reasoning quality.
- High System Efficiency: The architectural overhead is negligible at scale. A single 4B memory model server can support approximately 300 concurrent agent instances.
- Robustness: The trained memory model proved highly robust to "scaffold changes," maintaining effectiveness even when the agent's prompt templates or tool definitions were altered post-training.
Limitations and Future Directions
While highly effective, CoMem introduces a staleness trade-off. A larger $k$ (lag) improves speed by amortizing prefill costs, but it increases summary staleness. In extremely fast-paced environments where every single preceding step is critical, high $k$ values could degrade performance. Additionally, the current training pipeline requires generating computationally expensive "ground truth" trajectories from a full-context model to provide the RL reward signal.
Looking forward, the authors suggest combining CoMem with intra-model optimizations—such as sparse attention or KV cache quantization—for even greater efficiency gains. There is also significant potential in exploring "hierarchical" memory models to support agents operating over even longer time horizons.
Summary updated