MemCollab: Cross-Agent Memory Collaboration via Contrastive Trajectory Distillation
*An accessible walkthrough of the MemCollab paper, originally published as a Feynman-style explainer on zhichai.net.*
The Problem: AI Memories Are Silos
AI agents accumulate memory — solution techniques, mistakes, tool-use tricks — from past experience. But these memories are locked inside each agent. The paper identifies three issues with isolated memory:
- Redundant work: multiple agents solving the same task cannot share lessons learned.
- Capability boundaries: can a 7B model's memory help a 32B model, or vice versa?
- Resource waste: real systems deploy models of many sizes, each building memory independently.
- MATH500: Qwen2.5-7B drops from 52.2% to 50.6% when using memories transferred from a 32B model.
- HumanEval: accuracy falls from 42.7% to 34.1%.
- Violation patterns: systematic errors seen in failures (e.g., "premature numerical computation before building full equations", "enumerating cases while omitting boundary conditions").
- Reasoning invariants: principles present in successes and missing or broken in failures (e.g., "establish dependency relations between variables first", "model joint probability via conditional probability"). 3. Store rules, not examples: memories take the form "Do X; avoid Y" — abstract, actionable, and transferable rather than tied to specific problems. 4. Task-aware retrieval: a two-stage mechanism first classifies the new problem (algebra vs. geometry vs. probability, etc.), then ranks and retrieves only the top ~3 memories within that category.
- Cross-model contrast beats self-contrast: a model comparing its own successes and failures improves less than contrasting across models — different perspectives are key to filtering bias.
- Efficiency: fewer average reasoning rounds, since known dead-end paths are pruned.
- Inverted-U memory curve: performance rises with 1–3 retrieved memories, then declines beyond ~3, as irrelevant constraints add noise.
- Small models catch up: with MemCollab, the 7B model approaches or exceeds the memoryless 32B model.
- From isolated to collective AI: a shared memory mechanism turns individual agents into a collaborating team with a common, growing knowledge base.
- Cheaper AI: small models can "stand on the shoulders" of larger ones, lowering cost and deployment barriers for edge and enterprise settings.
- Foundation for multi-agent systems and continual learning: shared memory can evolve as agents learn new techniques and encounter new failure modes.
- Scaling from two-agent contrast to communities of many agents (collective wisdom).
- Moving from explicit rules toward meta-learning — teaching models to recognize problem structure.
- Self-evolving memory: automatic pruning, weighting, and organization into knowledge graphs.
- Extension to cross-modal domains: visual reasoning, robot control, scientific discovery.
Naive Sharing Backfires
Directly copying memories between models *degrades* performance:
The cause is what the authors call knowledge entanglement: memories mix genuinely transferable principles (correct reasoning steps, transferable constraints, error patterns) with model-specific biases (reasoning style, tool-use habits, idiosyncratic heuristics). Copying memory transfers the whole bundle, so noise drowns the signal.
The Core Idea: Contrastive Trajectory Distillation
MemCollab exploits the observation that comparing one success and one failure on the *same* task reveals what is task-essential rather than model-specific.
Method
1. Pair agents: a weaker agent (e.g., 7B) and a stronger agent (e.g., 32B) attempt each task independently; a verifier labels trajectories as preferred (τ+) or non-preferred (τ−). Either agent can produce the successful trajectory. 2. Contrast trajectories to extract:
Why It Works
Modeling each trajectory as τ = g(s, b), where *s* is task structure and *b* is agent bias, contrasting success and failure isolates *s* while filtering *b* — the same principle behind contrastive learning. From an information-theoretic view, it is a distillation that maximizes retained task-structure information while minimizing model-bias information and noise.
Results
MATH500 (math reasoning):
| Model | No memory | MemCollab | Gain | |---|---|---|---| | Qwen2.5-7B | 52.2% | 67.0% | +14.8% | | Qwen2.5-32B | 68.0% | 73.8% | +5.8% |
MBPP (code generation):
| Model | No memory | MemCollab | Gain | |---|---|---|---| | Qwen2.5-7B | 47.9% | 57.6% | +9.7% | | Qwen2.5-32B | 59.4% | 64.3% | +4.9% |
Cross-family transfer:
| Model | No memory | Cross-family MemCollab | Gain | |---|---|---|---| | LLaMA3-8B | 46.6% | 74.4% | +27.8% |
Additional Findings
Broader Significance
Future Directions
Reference
Chang, Y., Wu, Y., Wu, Q., & Lin, L. (2026). MemCollab: Cross-Agent Memory Collaboration via Contrastive Trajectory Distillation. *arXiv preprint arXiv:2603.23234*.