What SAM Is
This forum post discusses SAM (State-Adaptive Memory for Long-Horizon Reasoning Agent), arXiv: 2605.24468, by Yuyang Hu, Hongjin Qian, et al. (Renmin University of China GSAI & Beijing Academy of Artificial Intelligence). Code: github.com/qhjqhj00/cabeza.
The core thesis: long-horizon agents fail not because context windows are too short, but because "needed information appears far away and only becomes relevant late." Truncation, compression, and similarity retrieval all miss one thing — they never explicitly model how memory access should adapt to the agent's evolving state. SAM reframes this as a state-adaptive memory problem: how to let the agent reconstruct the right information, from the right point in history, at the right moment.
Cue-Page Dual-Track Architecture
SAM splits interaction history into two coupled components:
- Cues: compact, continuation-oriented summaries kept in the active context — what a page established, ruled out, left unresolved, and what may matter later. Cues are lightweight navigation handles, not compressed replacements of pages.
- Pages: complete raw trajectory segments (reasoning, tool calls, observations, feedback), stored externally, split at a 32K token budget with local temporal coherence.
- At management-trigger moments, SAM shows more tool calls, higher confidence, and higher accuracy than summary — intent-driven recall leads to more decisive states, not context noise.
- The advantage grows with episode length; the SAM-over-summary gap remains clear even beyond 80 turns, where single rolling summaries start losing useful state.
- 32K page size performs best; smaller loses local coherence, larger burdens recall.
- The same 9B memory model transfers across both backbones — the design is modular and model-agnostic.
- Separation of concerns: backbone handles reasoning, memory module handles context management — like the CPU/MMU split in operating systems. SAM aims to be the agent's MMU.
- Task-level training signal: OAT-GRPO's anchor recoverability reward asks not "is the summary accurate?" but "did the recall enable the right decision?" — aligning memory optimization directly with final task utility.
Write path: trajectory accumulates → split into 32K pages → memory model generates a cue per page (M_sum) → pages move to external storage, cues stay visible.
Read path: agent emits a recall intent → selects candidate cues from the memory bank → memory model reconstructs decision-relevant content from corresponding pages (M_rec) → reconstructed content is injected into the active context.
Active context = initial instruction + recent uncompressed trajectory + memory bank (all cues) + recalled content.
Training: Imitate Experts, Then Optimize for Task Utility
The memory model (Qwen3.5-9B) is a standalone module; the agent backbone (GLM-4.7 or Qwen3.5-35B-A3B) is frozen.
1. Expert-guided SFT: expert trajectories from strong models, rejection-sampled to keep only memory operations from successful runs. 2. OAT-GRPO (Online Anchor Tree GRPO): end-to-end RL in the full agent environment, with credit assignment across the memory-call tree and an anchor recoverability reward — rewarding whether recalled content enables correct decisions, i.e., trajectory-level utility rather than local summary quality.
Experimental Results
Setup: 128K context window, management triggered at 64K, 32K pages, max 40 turns per query, avg@3 over three rollouts; tools: search, visit, scholar, python, memory.
Baselines: w/o CM (keep everything until 128K overflows), discard-tool, recent-k, and rolling summary (strongest heuristic baseline).
SAM significantly outperforms both the summary baseline and w/o CM on all four benchmarks: BrowseComp, BrowseComp-ZH, WideSearch, and HLE.
Key findings:
How SAM Differs from Related Work
| Approach | Limitation | SAM's improvement | |---|---|---| | Truncation (w/o CM) | Fails on long trajectories | Proactive management | | Discard tool responses | Dropped info may matter later | Keep all, recall on demand | | Recent-k | Distant info permanently lost | Intent-driven recall of distant pages | | Rolling summary | Detail loss, state drift | Cues as handles, pages kept intact | | Memorix | Needs pretraining, not modular | Standalone module, no backbone changes | | agentmemory | Semantic retrieval, not intent-driven | Intent + reconstruction | | ReasoningBank | Only learns from failures | Full-trajectory management |
Limitations
1. Only 9B (full-parameter) and 27B (LoRA) memory models tested. 2. Validated only on web browsing / knowledge-intensive benchmarks; software engineering, embodied, and long-form generation settings are untested. 3. Both SFT and RL depend on strong expert models (GLM-4.7 / Qwen3.5-35B) for trajectories and rewards — costly, and may inherit expert bias.
The Author's Take
The poster argues SAM's real contribution is redefining memory's role: from a storage problem (how to pack/compress more) to a navigation problem (the agent needs a map system to reconstruct history on demand). Two deeper insights:
> Reference: Yuyang Hu, Hongjin Qian, et al., "SAM: State-Adaptive Memory for Long-Horizon Reasoning Agent", arXiv:2605.24468, 2026. Code: https://github.com/qhjqhj00/cabeza