Coding Agent Memory Post-training

Teaching agents
to remember
with files.

Language models already know how to work with files. CAMG-RL teaches them what is worth remembering—and how to use it when the context is gone.

54.4%Average task success
+6.4ppvs. CompactionRL

One policy. Four kinds of long-horizon work.
See what it can do ↓

The conversation ends. The work continues.01 → 02
CODING / SCRAPY

Keep the fix.
Resume the work.

.agent_memory/CONTINUATION.md
objective: fix response logging
evidence: added _mqpush
  in scrapy/core/scheduler.py
tested: no _mqpush error
next: run tests, confirm
  logging, then submit
Save the diagnosis and next steps
a fresh context
↳
Read the file. Continue testing.

The work survives in a file the agent can read.

A real Scrapy training episode.
Follow the fix through to the tests ↓

Lirui Luo · Kelong Mao · Heming Xia · Rongqing Li · Xinwei Yang · Luyu Chen · Kieran Wong · Yudong Guo · Xinrui Wang · Jiayin Zhu · Simiu Gu · Sulong Xu · Cong Fang

JD.com

01 / Start with a familiar skill

Read. Write. Search. Revise.
The model already knows how.

An agent can use ordinary files to keep a plan, save evidence, or leave itself a next step. CAMG-RL builds on these familiar operations to learn useful memory.

A head start,
before training begins.

The base model is already more familiar with ordinary file operations than with dedicated memory tools.

Reinforcement learning turns that familiarity into a practical skill: deciding what to keep and how to use it later.

Store

File operations1.19
Dedicated tools1.40

Retrieve

File operations0.08
Dedicated tools0.47

Revise

File operations0.25
Dedicated tools0.27

Remove

File operations0.27
Dedicated tools0.33
Negative log-likelihood per action token · lower means more familiar
01

Shop

Preferences and product evidence.

02

Coding

Diagnoses, patches and test results.

03

DeepResearch

Sources, findings and open questions.

04

AutoResearch

Hypotheses, experiments and discoveries.

ACT & REMEMBEROne policy

Work on the task. Write and read files.

KEEP WHAT MATTERSA persistent workspace

Carry useful information into the next context.

LEARN FROM THE OUTCOMETask reward

Success trains both acting and remembering.

02 / Remember better. Finish more.

One shared policy.
More work carried through.

54.4%

Average success across
Shop, Coding, DeepResearch
and AutoResearch.

+6.4 percentage points

over CompactionRL

The biggest gains are in Coding and AutoResearch, where keeping track of intermediate work is especially valuable.

Average task success (%)
Qwen3.5-4B17.4%
Mem019.7%
Letta Code17.8%
CompactionRL48.0%
AgeMem25.3%
CAMG-RL54.4%
0204060

All methods use Qwen3.5-4B. Evaluated on 512 held-out tasks.

Explore the four environments

Swipe or scroll horizontally to see all columns →

Task success (%)
MethodShopCodingDeepResearchAutoResearchAverage
Qwen3.5-4B11.610.936.710.217.4
Mem015.614.837.510.919.7
Letta Code12.614.832.011.717.8
CompactionRL97.519.550.824.248.0
AgeMem16.726.628.129.725.3
CAMG-RL97.126.655.538.354.4

03 / The saved content matters

Erase the memory.
Watch the agent lose ground.

Resume the same tasks from the same state, but empty or shuffle the saved files. Success falls across all four environments.

−14.1pp

Average success lost in this memory test
when the saved memory is emptied.

The files carry information the agent actually uses to continue its work.

Empty fileShuffled content

Shop

-29.4
-14.4

Coding

-13.8
-6.5

DeepResearch

-4.8
-16.7

AutoResearch

-8.3
-8.3

← Lower success   ·   right edge = no change

Change in task success after a context reset (percentage points)

04 / A skill that travels

Useful memory reaches
beyond its original setting.

New tools.
The same learned memory skill.

The learned policy improves memory through both Claude Code file tools and AgeMem’s dedicated tools—without further training.

The task-execution policy is held fixed; only the policy managing memory changes.

Claude Code file tools

Before training15.9
Learned memory27.3

AgeMem memory tools

Before training14.3
Learned memory20.7
Average task success (%)

Keep what matters.
Work with a smaller context.

CAMG-RL’s learned file memory, with a 30,720-token active context, outperforms a 262K-context agent using automatic compaction.

Same base model and PPO training budget; different context-management strategies.

262K + automatic compaction49.2%
CAMG-RL (30,720 active tokens)54.4%
+5.2 ppaverage task success

Beyond the training environments.

Both the 4B and 9B models carry their gains to software-engineering and machine-learning benchmarks.

SWE-bench Verified

4B

Base model7.6
CAMG-RL15.8

9B

Base model14.8
CAMG-RL27.6

MLE-bench Lite

4B

Base model0.0
CAMG-RL4.5

9B

Base model4.5
CAMG-RL9.1

Task success (%) · each trained model is compared with its own base

05 / Back to the task

A saved note becomes
the next useful action.

In the Scrapy episode, the agent has already made a fix. Before starting a fresh context, it leaves itself the diagnosis and the checks still to run.

SAVE THE STATE

What changed? What comes next?

objective: fix response logging
evidence: added _mqpush
  in scrapy/core/scheduler.py
tested: no _mqpush error
next: run tests, confirm
  logging, then submit

The file keeps the diagnosis, the code change, and the next step together.

PICK UP THE THREAD

Read the note. Run the checks.

cat .agent_memory/CONTINUATION.md
python test_spider.py
python -m pytest tests/test_crawl.py -v

In the fresh context, the agent reads its note and resumes testing.

FINISH THE WORK

The fix holds.

Passedhidden tests

The saved state has become useful action, carrying the task through to completion.

From a real training episode; excerpts shortened for readability.

Paper & resources

Coding Agent Memory Post-training

Unlocking the Memory Potential of Pre-trained File Operations for Long-Horizon Tasks via Reinforcement Learning

Lirui Luo · Kelong Mao · Heming Xia · Rongqing Li · Xinwei Yang · Luyu Chen · Kieran Wong · Yudong Guo · Xinrui Wang · Jiayin Zhu · Simiu Gu · Sulong Xu · Cong Fang

JD.com

Cite this work
@article{luo2026coding,
  title={Coding Agent Memory Post-training: Unlocking the Memory Potential of Pre-trained File Operations for Long-Horizon Tasks via Reinforcement Learning},
  author={Luo, Lirui and Mao, Kelong and Xia, Heming and Li, Rongqing and Yang, Xinwei and Chen, Luyu and Wong, Kieran and Guo, Yudong and Wang, Xinrui and Zhu, Jiayin and Gu, Simiu and Xu, Sulong and Fang, Cong},
  journal={arXiv preprint arXiv:2609.34422},
  year={2026}
}