TL;DR
CoReMem is a novel framework for coding agents that optimizes memory based on its actual "prospective value"—the effort it saves on future, unseen tasks. By focusing on "anchors" like specific repository locations and test commands, it enables agents to skip redundant exploration, increasing success rates while significantly reducing the computational cost (steps and tokens) of solving successive tasks.
What Problem Does This Paper Address?
In real-world software engineering, developers don't just solve one isolated bug; they work on a sequence of tasks within a single, evolving repository. Each task inherits the state left by the previous one. Ideally, a coding agent should "remember" what it learned during one task to work more efficiently on the next.
However, existing memory methods for AI agents often fail in this "successive-task" setting. They either focus on compacting context for the current task or distilling general insights across different repositories. Crucially, they rarely account for the cost of memory. If an agent spends more tokens reading a long memory than it saves by skipping exploration steps, the memory is a net negative. The core challenge is determining what information is actually worth carrying over when the future task is unknown, and training the agent to use that information to save effort.
Methods
The authors introduce CoReMem (Coding-Repository Memory), which uses two key innovations:
- Prospective Segment Valuation: To decide what to store, the authors ran "ablation" experiments. They took a completed task's trajectory, split it into segments (e.g., reasoning, commands, test output), and measured how much effort was saved on the next task when each segment was provided as memory. This revealed that "anchors"—specific file locations and executable test commands—are the most valuable pieces of information.
- On-Policy Adaptation with Provenance-Gated Value Credit: Even with good memory, an agent needs to be trained to use it efficiently. CoReMem uses a reinforcement learning (RL) approach with a "cost-internalizing" reward that penalizes the number of steps taken. To ensure the agent learns specifically from the memory, they use a provenance gate: only steps that actually utilize an "anchor" from the memory receive a "value credit" based on the overall effort saved.
Datasets
The researchers evaluated CoReMem across several benchmarks:
- ChainSWE: A newly introduced benchmark consisting of 100 chains of successive real-world GitHub issues, where each task inherits the repository state from the previous one.
- SWE-bench Verified: A standard benchmark for evaluating AI agents on software engineering tasks.
- SWEContextBench & SWE-Bench-CL: Used to test the model's ability to handle cross-task dependencies and continual learning.
- OpenHands: An open-source platform for AI software developers used for additional cross-harness validation.
Key Insights and Ideas
- Anchors > Narratives: One of the most striking findings is that an agent's internal reasoning or detailed "scratchpad" notes are almost worthless for future tasks. What actually saves time are "anchors": where the relevant code is and what command verifies the fix.
- Internalizing the Cost of Thinking: By explicitly penalizing step counts in the RL reward, the agent learns to treat its own "thinking time" and exploration as a cost to be minimized, leading to more direct and efficient problem-solving.
- Traceable Memory Use: The "provenance gate" solves a common credit assignment problem in RL. Instead of giving a generic reward for a successful session, it specifically rewards the agent for using the provided memory to skip steps, making the training much more stable and effective.
Key Results
CoReMem demonstrated significant improvements across multiple models (including Qwen, Gemma, and Claude):
- Efficiency Gains: On the ChainSWE benchmark, a 27B parameter actor model using CoReMem solved 22% more tasks while using 17% fewer steps and 11% fewer total tokens compared to a baseline without memory.
- Resolve per Token: The "resolve per thousand tokens" metric—a measure of how much "work" the model gets done per unit of compute—increased by 41% on average across three different actor models.
- Outperforming Baselines: CoReMem was the only method tested that consistently landed in the "ideal" quadrant of reducing both steps and total token usage while improving success rates.
Limitations and Future Work
- Language Specificity: The primary experiments were conducted on Python repositories. While the "anchor" concept is general, its effectiveness in other languages remains to be fully explored.
- Long-term Scaling: The study focused on relatively short chains of tasks. How memory should be managed, refreshed, or "forgotten" over very long repository histories (hundreds of tasks) is an open question.
- Hardware Metrics: The paper measures effort in terms of steps and tokens but does not report wall-clock latency or actual energy consumption, which are important for real-world deployment.
Summary updated