ByteDance Trains CoMAM to Make AI Memory Agents Work Together
A new reinforcement learning framework trains memory agents together instead of separately, boosting long-conversation QA accuracy by up to 16.7 percent.
ProTakeaways
- CoMAM jointly trains three memory agents end-to-end with RL instead of the usual one-at-a-time approach.
- Pipeline is modeled as a sequential MDP so upstream decisions shape downstream training signals.
- Adaptive credit uses NDCG ranking consistency between local rewards and final QA accuracy.
- Beats Memory-R1 by 8.5 to 16.7 percent on PersonaMem across 32K, 128K, 1M contexts.
- Scores F1 62.17 on LongMemEval versus 51.75 for the best prior RL memory system.
- No public code release; training also requires annotated evidence spans for local rewards.
Giving a language model a persistent memory usually means wiring up several small agents: one to extract facts from a conversation, another to summarize preferences, and a third to fetch the right snippets when a question comes in. The standard playbook is to train each of those agents on its own, then hope they cooperate at inference time. A new paper from the University of Science and Technology of China and ByteDance Seed argues that this is exactly where things break, and proposes a joint training scheme called CoMAM that closes the gap.
Why solo training keeps failing
Memory systems have become a standard workaround for the context window limits of LLMs. They are typically implemented as multi-agent pipelines, where construction agents summarize and store user history into multi-granular memories, and retrieval agents select and integrate relevant memories for downstream queries. Recent RL-based systems like Memory-R1 and Mem1 optimize these agents one at a time under a shared final objective such as QA accuracy.
The authors identify two specific problems with that setup:
- Ignored dependencies. When you train the retrieval agent while freezing the memory constructor, the retriever adapts to a static upstream policy that will change later.
- Ambiguous credit. A single global reward like final answer accuracy tells three specialized agents almost nothing about which of them actually helped.
Their opening figure makes the point starkly: although agents can be well trained independently with converged reward curves, combining them directly leads to inferior system performance compared to joint optimization across different context lengths.

Three agents, one Markov decision process
CoMAM keeps the familiar three-agent decomposition but retrains them together. The pipeline consists of:
- Extraction Agent - reads raw conversation history and produces fine-grained memory (key facts and events). Rewarded on evidence coverage, with a coverage-heavy weighting of
alpha = 0.8. - Profile Agent - abstracts coarse-grained memory such as stable user preferences from the extracted facts. Scored by a frozen LLM judge against rubrics for scenario, preference, and persona quality.
- Retrieval Agent - selects the top-k relevant memories and generates the final answer, judged on both retrieval precision (
beta = 0.2) and a binary answer-correctness signal.
The critical move is treating the whole pipeline as a sequential Markov decision process. Each step corresponds to a heterogeneous agent executing its policy, and the transition function propagates intermediate outputs, where each agent's output becomes part of the next agent's input, explicitly exposing inter-agent dependencies. That framing lets gradient signals flow across the whole trajectory rather than dying at each agent boundary.
Credit assignment by ranking consistency
End-to-end training alone still leaves the credit assignment problem: which agent deserves the blame or reward for a wrong answer? CoMAM handles this with an adaptive weighting scheme built on Normalized Discounted Cumulative Gain (NDCG), a ranking metric borrowed from information retrieval.
For each batch of sampled trajectories the framework collects both local rewards (per-agent task scores) and the global reward (final answer accuracy). It then measures how well each agent's local reward ranking matches the global reward ranking. Agents whose good local behavior consistently correlates with correct final answers get a larger share of the global reward:
v_n = NDCG(rank(local_rewards_n), rank(global_rewards))
w_n = softmax(v_n)
r_final_n = r_local_n + w_n * r_global
Each agent is then optimized with GRPO, the critic-free RL algorithm popularized by DeepSeek, on those integrated rewards. Compared to value-based metrics, ranking-based measures are more robust under sparse and noisy rewards, as they rely on relative ordering rather than absolute magnitudes.
Numbers on long conversations
The team evaluates on two long-horizon benchmarks. PersonaMem supplies conversation histories at 32K, 128K, and 1M tokens paired with seven question types (fact recall, preference tracking, recommendation, and so on). LongMemEval tests multi-session tracking and temporal reasoning. Backbones are Qwen2.5 (3B for construction agents, 7B for retrieval) and Llama-3.2/3.1 in matching sizes.
On PersonaMem, CoMAM lifts multiple-choice accuracy meaningfully over the best RL baseline, Memory-R1:
| Context | Memory-R1 (Qwen) | CoMAM (Qwen) | Gain |
|---|---|---|---|
| 32K | 0.58 | 0.64 | +8.5% |
| 128K | 0.60 | 0.70 | +16.7% |
| 1M | 0.60 | 0.66 | +10.0% |
On LongMemEval with Qwen2.5-7B, CoMAM reports F1 of 62.17 against 51.75 for the previous best RL memory system, GAM.
What the ablations reveal
The paper runs a fairly thorough teardown of its own design. A few results stand out:
- Heterogeneous policies matter. A single shared policy across the three roles caps out around 0.60 accuracy at 128K, while separate policies plus end-to-end RL reach 0.70. Specialization is doing real work.
- Local plus global beats either alone. Training with only local rewards or only the final answer reward both underperform the combined signal, and uniform global weighting underperforms the NDCG-based adaptive scheme.
- Faster wall-clock convergence. Because joint training updates every agent in parallel, total convergence steps drop from 790 (independent) to 350 at the 128K setting, since the total is bounded by the slowest agent rather than a sum.
Where this is useful and where it is not
CoMAM is a training-side contribution rather than a new inference architecture. If you are already running a multi-agent memory stack and paying the training cost of RL, the pattern here is worth adopting: model the whole pipeline as an MDP, keep per-agent local rewards, and use ranking consistency to distribute the global signal. It is particularly relevant for long conversational assistants where the memory constructor and retriever need to co-adapt.
The paper does not appear to release code, weights, or a public repository, and the authors themselves flag limitations. They adopt a compact set of agents to focus on core collaborative behaviors, and more advanced functionalities such as memory editing, consistency maintenance, and redundancy removal are not explicitly modeled. The training pipeline also depends on annotated ground-truth evidence spans to compute construction and retrieval rewards, which adds up-front labeling cost even if it does not affect inference.
The larger takeaway is that the memory-system arms race is moving from prompt engineering to system-level RL. Treating a compound LLM pipeline as one differentiable object, with per-role rewards weighted by their measured contribution, is a template that likely extends well beyond memory into tool-using and search agents.