GAM Deep Dive: Turning 'Deep Research' into a JIT Compiler for Memory Systems
One-line conclusion: The fundamental flaw of existing AI memory systems is treating "memory" as "pre-digested answers." GAM (General Agentic Memory) makes a counterintuitive move: memory should not replace search — it should support search, just as a JIT compiler doesn't translate code ahead of time but optimizes on demand at runtime.
> "Intelligence is not the ability to store information, but to know where to find it." — Albert Einstein
Why AOT Memory Systems Fail
Mainstream systems (MemGPT, Mem0, A-Mem) all follow an Ahead-of-Time compilation paradigm: offline, raw history is heavily compressed into lightweight memory; at runtime, the system just looks up the precomputed memory. This has three fatal defects:
1. Irreversible information loss — compression destroys fine-grained details, like condensing a 500-page book into 5 pages of notes. 2. Static structure cannot adapt to dynamic query needs — every query gets the same precomputed notes. 3. Heavy domain dependence — what to keep/discard relies on hand-crafted heuristics that break when the domain changes.
GAM's JIT Philosophy
| | AOT Memory | GAM (JIT Memory) | |---|---|---| | Offline | Heavy compression into memory | Lightweight index + full raw data (page-store) | | Runtime | Look up precomputed memory | Deep research: dynamic retrieval + integration | | Adaptivity | Zero | High — customized per request | | Fidelity | Severe loss | Theoretically lossless |
GAM stores the complete history in a page-store and builds a lightweight memory as a navigation map for search.
Memorizer (offline)
- Memorizing: generates memos — not session summaries, but records of what each session contributes to the whole trajectory.
μ_i = Memorizer.memorize(s_i, m_i). - Paging: each page =
{header, content}— the header is contextual metadata (inspired by BGE landmark retrieval and Anthropic contextual retrieval) that aids retrieval; the content is the complete raw session, nothing dropped. - All three search tools (53.18 F1) > any two (≈51) > any single (28.96–48.64).
- "Integration + raw pages" performs best (55.71) but costs 22x the tokens of the default integration-only output (53.18 F1 at ~106 tokens).
- The Researcher needs far more model capacity than the Memorizer: 0.5B → 9.08 F1 vs 14B → 53.18; the Memorizer saturates around 14B.
- On HotpotQA 56K, GAM's online serving takes 12.43s (vs 0.15–0.55s for baselines), but its total pipeline time is comparable to Mem0/MemoryOS, and the quality gain is massive (64.07 vs best baseline 37.30).
- Latency makes GAM unsuitable for real-time chat scenarios.
- Longer history isn't always better — performance can be non-monotonic with context length.
- Gains come mainly from architecture, not raw scale.
Researcher (online): Plan → Search → Reflect
1. Planning: analyzes the query against the lightweight memory to decide what information is needed — memory *hints at search directions*, it does not provide answers. 2. Searching: runs Embedding, BM25, and ID retrieval in parallel, integrating results cumulatively via union rather than intersection. 3. Reflection: self-judges whether the gathered information suffices; if not, formulates a focused follow-up request and repeats — up to 3 rounds in experiments.
Ablation: with the full memory + Researcher, F1 = 53.18; memory alone without the Researcher (i.e., a traditional AOT system) drops to 27.50.
End-to-end Reinforcement Learning
The objective: find the shortest context that maximizes task performance. Memorizer and Researcher are both trained with REINFORCE-style policy gradients using task reward, so the Memorizer learns what memories best aid search, and the Researcher learns how to plan/integrate for maximum reward.
Experimental Results
LoCoMo benchmark (GPT-4o-mini, F1): GAM leads on all four task types — Single Hop 57.75, Multi Hop 42.29, Temporal 59.45, Open Domain 33.30 — beating RAG, Mem0, and LONG-LLM.
HotpotQA multi-hop QA (Qwen2.5-14B): GAM scores 64.07 (56K), 55.99 (224K), 57.87 (448K) — roughly 12 points above RAG at 56K — while Mem0 collapses to 26.55 at 448K, exposing static memory's information loss.
RULER (GPT-4o-mini): GAM achieves 97.70 retrieval, 93.20 multi-hop tracing (vs 0.00 for RAG), 42.50 aggregation, 72.50 QA — showing agentic iterative research is a necessity for multi-hop reasoning, not a luxury.
Ablations:
Efficiency and Limitations
Takeaway
GAM's JIT philosophy generalizes: don't do all computation upfront; keep raw data and let an agent research on demand. Indexes can be lightweight, but raw data must be preserved; retrieval can be intelligent, but it must be iterative; integration is dynamic, and the agent itself must decide when it has "enough." GAM redefines AI memory: memory is not an answer repository but a navigation map for search, and the agent is a deep researcher, not a query executor.
Paper: Yan B.Y., Li C., Qian H., Lu S., Liu Z. "General Agentic Memory Via Deep Research", arXiv:2511.18423 (2025). Institutions: BAAI, Renmin University of China, Peking University, PolyU. Code: https://github.com/VectorSpaceLab/general-agentic-memory