What CoReMem Gets Right About Coding Agent Memory

What CoReMem Gets Right About Coding Agent Memory

6 min read

A new framework called CoReMem treats agent memory as something with a measurable cost and value, not a bottomless notebook, and the gains on successive coding tasks suggest that framing is the point most memory systems miss.

TL;DR: CoReMem treats agent memory as a thing with a price, measuring what each saved note is actually worth on the next task before it keeps it, and that framing lifts a 27B coding agent’s resolve rate from 21.0% to 25.7% while using fewer steps and fewer tokens.

Most memory systems for coding agents work like a packrat. The agent finishes a task, dumps a pile of notes about what it did, and hopes some of that helps later. The problem is that writing memory costs tokens, reading it costs tokens, and a note that sounded useful at write time can be dead weight or an active distraction when the next task shows up. Nobody usually measures whether the note earned its keep.

CoReMem, from the paper “CoReMem: Cost-Internalizing Memory for Successive Coding Tasks with Prospective Valuation” (posted to arXiv cs.AI and cs.CL), takes the opposite stance. It asks a blunt question of every piece of memory: does keeping this actually make the next task cheaper to solve? If it can’t show that, it doesn’t get stored.

What problem is CoReMem actually solving?

The setup is specific and worth getting right, because it’s where most agent benchmarks don’t live. A coding agent works on an evolving repository across a sequence of tasks. It edits code, carries those edits forward, and writes memory before it knows what the next task will be. That last part is the hard constraint. You’re deciding what to remember for a task you haven’t seen yet.

That creates three decisions tangled together. What to write (and pay the write cost). What to read back later (and pay the read cost). And when to actually act on memory versus just figuring things out fresh. Standard retrieval-augmented approaches treat memory as free and infinite: stuff everything into a vector store, pull back the top matches, let the context window sort it out. On a single Q&A turn that’s fine. On a chain of coding tasks against a live repo, the costs compound and the irrelevant notes start crowding out the signal.

a packrat's cluttered pile of notes on one side, a small set of labeled anchor points pinned to a structure on the other

The authors frame this as “cost-internalizing,” which is a good name for a real idea. Instead of treating memory as a side effect, you fold its cost directly into how the agent is trained and how the memory is built. Memory has to pay for itself.

How does prospective segment valuation work?

Here’s the clever part. To decide whether a chunk of a past trajectory is worth remembering, CoReMem runs the next task twice from the same inherited repository state: once with that trajectory segment available, once without it. The difference in outcome is the segment’s measured value. They call this prospective segment valuation.

It’s a counterfactual test, applied per segment. Not “did this note look relevant” but “did having this note change whether the next task got solved, and at what step cost.” That’s a much stricter bar, and it’s the right one.

What survives the test gets compressed into what the paper calls anchors: concrete repository locations and executable checks. Not prose summaries of what happened, but pointers to where in the code something matters and tests you can actually run to verify state. That choice matters. A natural-language memory note (“I refactored the auth module”) is vague and easy to misread. An anchor that says “this file, this function, run this check” is something an agent can act on without re-deriving it.

two parallel runs of the same task branching from one shared starting point, one path shorter than the other

Why train the actor on memory value, not just build better memory?

This is the second half, and it’s what separates CoReMem from a smarter retrieval scheme. Building good memory isn’t enough if the agent doesn’t know when to use it. So CoReMem also adapts the actor itself.

During training, it estimates on-policy memory value within rollout groups, again by running with and without memory. The reward prioritizes actually resolving the task and penalizes step count on successful runs, so the agent is pushed toward solving things in fewer moves. Then there’s a mechanism they call provenance-gated value credit: the extra reward tied to memory only goes to the specific steps that used a memory-supplied anchor. Every step still gets outcome credit, but the memory bonus is targeted at the steps that actually consumed memory.

In plain terms: the agent learns not just to have memory but to recognize when acting on an anchor saves work versus when to just proceed. That’s the “when to act on memory” decision the setup demanded, and training it directly is more honest than hoping it emerges.

Do the numbers hold up?

On the ChainSWE benchmark, the 27B actor goes from a 21.0% resolve rate to 25.7%. That’s a 4.7-point absolute gain, which in SWE-style coding tasks is meaningful and not a rounding error. It comes with 17% fewer steps and 11% fewer total cache-aware tokens, and the token count includes the memory-module calls themselves. So the memory overhead is counted against the system, not hidden off the books. That last detail is what I trust most here, because plenty of memory papers quietly exclude their own retrieval cost from the ledger.

I’d want to see a few things the sources don’t cover. The results are on a single benchmark with a single model size, so I can’t tell you yet whether the gains hold at 7B or at frontier scale. The counterfactual training loop (run every task with and without each segment) is expensive, and the paper here doesn’t give the training compute cost, so the real question is whether the one-time training price is worth the per-task savings at inference. And ChainSWE is one task distribution; a repo full of novel, unrelated features is a harder test for any memory system than a repo where tasks rhyme.

Still, the direction is right. The field has been treating agent memory as a storage problem. CoReMem treats it as an economics problem: every note has a cost and has to earn a return.

I run a practice where I care a lot about systems that keep working after the demo, so the framing lands for me. If you’re building a coding agent today, you don’t need CoReMem’s full training loop to use the core insight. Start measuring. Before you keep a piece of memory, run the counterfactual at least on a sample: does the next task get solved faster with it than without? Prefer anchors (file paths, function names, runnable checks) over prose summaries, because they’re cheaper to store and harder to misread. And count your retrieval tokens against your own budget, not as free overhead. The catch most readers will miss: the win here isn’t a bigger memory store, it’s a smaller one that’s been pruned by evidence. More notes almost always makes agents worse, not better.