SAM: State-Adaptive Memory for Long-Horizon Reasoning Agent
MemoryAgentRL中国人民大学北京智源人工智能研究院SAM:面向长时程推理智能体的状态自适应记忆
Abstract
Long-horizon agentic reasoning requires large language models to act over long interaction histories containing thoughts, tool calls, observations, and partial conclusions. The challenge is not merely that these histories grow long, but that information needed for the current decision may be scattered across distant steps and only become relevant later. Existing approaches address this difficulty by truncating the interaction history, compressing it into shorter surrogates, or retrieving selected parts of it for reuse, but they do not explicitly model how access to past interaction should adapt to the agent's evolving state. We instead cast long-horizon reasoning as a problem of state-adaptive memory.
长时程智能体推理要求大语言模型基于包含思考、工具调用、观测和阶段性结论的长交互历史采取行动。 挑战不仅在于这些历史不断变长,还在于当前决策所需的信息可能分散在相隔很远的步骤中,并且直到后来才变得相关。 现有方法通过截断交互历史、将其压缩为更短的替代表示,或检索其中的部分内容以供复用来应对这一困难,但它们并未显式建模:对过去交互的访问应如何适应智能体不断变化的状态。 我们则将长时程推理视为一个状态自适应记忆问题。
To this end, we propose State-Adaptive Memory (SAM), a standalone framework that consolidates ongoing interaction into compact memory cues while preserving raw trajectory pages for intent-driven recall. These cues are not treated as replacements for history; rather, they serve as lightweight handles that allow the agent to reconstruct temporally distant information according to its current needs, without retraining the underlying backbone. We further optimize the memory module through expert-guided supervision and reinforcement learning, aligning it with trajectory-level utility. Across BrowseComp, BrowseComp-ZH, WideSearch, and HLE, SAM consistently outperforms strong baselines over diverse agent backbones. Our results suggest that explicit memory modeling provides a simple and effective foundation for long-horizon agentic reasoning.
为此,我们提出状态自适应记忆(State-Adaptive Memory,SAM),这是一个独立框架,将持续发生的交互整合为紧凑的记忆线索,同时保留原始轨迹页,以支持意图驱动的回忆。 这些线索并非历史的替代品,而是轻量级索引,使智能体能够根据当前需要重建时间上相距较远的信息,无须重新训练底层骨干模型。 我们进一步通过专家指导的监督学习和强化学习优化记忆模块,使其与轨迹层面的效用对齐。 在 BrowseComp、BrowseComp-ZH、WideSearch 和 HLE 上,SAM 在多种智能体骨干模型下持续优于强基线。 我们的结果表明,显式记忆建模为长时程智能体推理提供了简单而有效的基础。
1. Introduction
Large language models (LLMs) are increasingly used as agents that reason and interact with external environments over extended horizons. Unlike single-pass generation, these tasks require the model to continually gather evidence, track progress, and choose subsequent actions based on a growing interaction history. As this history accumulates, it quickly becomes long and heterogeneous, interleaving thoughts, tool calls, observations, and partial conclusions. The resulting challenge is not only to continue reasoning, but also to recover what has already been established, what remains unresolved, and what information is needed next. For example, information encountered early in a trajectory may appear peripheral at first, yet later become critical for choosing the next action, ruling out an incorrect branch, or interpreting newly acquired evidence. Long-horizon agentic reasoning therefore poses a central problem of how to organize past trajectories so that it remains accessible to the current decision.
大语言模型(LLM)越来越多地被用作智能体,在较长时间跨度内推理并与外部环境交互。 与单次生成不同,这些任务要求模型根据不断增长的交互历史,持续收集证据、跟踪进展并选择后续行动。 随着历史不断累积,它很快就会变得冗长且异构,交织着思考、工具调用、观测和阶段性结论。 由此带来的挑战不仅是继续推理,还包括重新找出已经确立了什么、哪些问题仍未解决,以及接下来需要什么信息。 例如,轨迹早期遇到的信息起初可能显得无关紧要,但后来却可能成为选择下一步行动、排除错误分支或解读新获取证据的关键。 因此,长时程智能体推理提出了一个核心问题:如何组织过去的轨迹,使其仍能为当前决策所用。
Many existing approaches address this problem, at least in part, through context management. Common strategies include discarding interaction history, folding earlier steps into compact summaries, or retrieving selected past content for reuse. These methods can be effective when the information needed for the next step remains recent or can be adequately preserved in compressed form. However, long-horizon trajectories are often less forgiving: useful information may be distributed across distant steps, and its importance may only become apparent as the task unfolds. In such cases, the difficulty lies not only in limiting context length, but also in making past information available in a form that matches the agent's current needs.
许多现有方法至少在一定程度上通过上下文管理来处理这一问题。 常见策略包括丢弃交互历史、将早期步骤折叠为紧凑摘要,或检索选定的过去内容以供复用。 当下一步所需的信息仍在近期上下文中,或能够以压缩形式充分保留时,这些方法可以奏效。 然而,长时程轨迹往往提出更苛刻的要求:有用信息可能分散在相隔很远的步骤中,其重要性也可能直到任务推进后才显现。 在这种情况下,困难不仅在于限制上下文长度,还在于以符合智能体当前需要的形式提供过去的信息。
We argue that this challenge is better understood as one of state-adaptive memory. At any moment, an agent needs a coherent view of what has been established, what has been resolved, and what should be pursued next. Yet these elements are rarely presented explicitly in the raw trajectory; instead, they are scattered across a growing stream of loosely organized interaction history. A more natural view is that not all past information should remain equally active: as interaction unfolds, rich local context must gradually give way to a more compact form that still preserves what may later need to be recalled, echoing the classic distinction between active and more persistent memory states. From this perspective, the goal is not to keep the entire past in view, but to make the right parts of past information recoverable when the agent's current state demands them.
我们认为,将这一挑战理解为状态自适应记忆问题更为合适。 在任意时刻,智能体都需要连贯地了解 已经确立了什么、已经解决了什么,以及接下来应推进什么。 然而,这些要素很少明确呈现在原始轨迹中;相反,它们分散在不断增长、组织松散的交互历史流里。 一种更自然的观点是,并非所有过去的信息都应保持同等活跃:随着交互展开,丰富的局部上下文必须逐渐转为更紧凑的形式,同时仍保留日后可能需要回忆的内容,这呼应了活跃记忆状态与更持久记忆状态之间的经典区分。 从这一角度看,目标并不是始终将全部过去置于眼前,而是在智能体当前状态提出需要时,使过去信息中恰当的部分能够被恢复。
To this end, we propose State-Adaptive Memory (SAM), a standalone framework that equips an agentic LLM with an external memory model for trajectory consolidation and intent-driven recall. Rather than asking the agent to carry an ever-growing history forward, SAM converts ongoing interaction into two coupled forms: compact memory cues that remain visible in context as lightweight summaries and entry points for deeper recall, and raw trajectory pages preserved outside the live context window. Crucially, the cues are not treated as replacements for history; they act as persistent handles to the underlying pages. When the agent needs to revisit the past, it selects potentially relevant cues according to its current intent, and the memory model reconstructs the needed information from the corresponding pages. SAM therefore turns long-horizon history from a passive burden into a navigable memory space, enabling the agent to access temporally distant information on demand.
为此,我们提出 状态自适应记忆(SAM),这是一个独立框架,为智能体 LLM 配备外部记忆模型,用于轨迹整合和意图驱动的回忆。 SAM 不要求智能体不断携带日益增长的历史,而是将持续发生的交互转换为两种耦合形式:紧凑的记忆线索留在上下文中,充当轻量摘要和深层回忆入口;原始轨迹页则保存在实时上下文窗口之外。 关键在于,线索并不是历史的替代品,而是指向底层页面的持久索引。 当智能体需要回顾过去时,它会依据当前意图选择可能相关的线索,由记忆模型从对应页面中重建所需信息。 因此,SAM 将长时程历史从被动负担转化为可导航的记忆空间,使智能体能够按需访问时间上相距较远的信息。
This design also changes what it means to optimize memory. In SAM, memory is a representation whose value is realized only through future use: it must compress ongoing interaction, preserve information whose importance may surface only later, and remain recoverable under a changing decision state. We therefore optimize memory as an independent capability rather than absorbing it into a particular agent backbone: leading LLMs first validate the SAM framework, then this capability is transferred into a compact memory model via expert-guided supervision from rejection sampling, and finally refined with end-to-end RL (OAT-GRPO) in the full agent-environment loop. The result is a reusable memory module aligned with delayed, trajectory-level decision utility rather than local summary quality alone.
这一设计也改变了记忆优化的含义。 在 SAM 中,记忆是一种只有通过未来使用才能实现价值的表示:它必须压缩持续发生的交互,保留重要性可能直到后来才显现的信息,并在决策状态变化时仍可恢复。 因此,我们将记忆作为一种独立能力进行优化,而非将其吸收到某个特定智能体骨干模型之中:首先由领先的 LLM 验证 SAM 框架,再通过基于拒绝采样的专家指导监督,将这一能力迁移到紧凑的记忆模型中,最后在完整的智能体—环境循环中通过端到端 RL(OAT-GRPO)进一步改进。 最终得到的是一个可复用的记忆模块,它对齐的是延迟体现的、轨迹层面的决策效用,而不仅仅是局部摘要质量。
We evaluate SAM on four long-horizon agent benchmarks: BrowseComp, BrowseComp-ZH, WideSearch, and HLE. Across these settings, SAM consistently outperforms strong baselines over diverse agent backbones, indicating that explicit memory modeling can substantially improve long-horizon reasoning. Our contributions are threefold: (1) we formulate long-horizon context management as a state-adaptive memory problem, emphasizing demand-driven access to temporally distant information rather than recency-based compression alone; (2) we introduce a cue-page memory architecture that decouples lightweight write-time consolidation from intent-conditioned read-time reconstruction over preserved raw trajectory pages; and (3) we develop an optimization recipe for standalone memory models, combining expert-guided supervision with OAT-GRPO, a memory-action-level RL objective that assigns credit through memory-call trees and oracle-anchored recoverability rewards.
我们在四个长时程智能体基准上评估 SAM:BrowseComp、BrowseComp-ZH、WideSearch 和 HLE。 在这些设置下,SAM 在多种智能体骨干模型上持续优于强基线,表明显式记忆建模能够显著改善长时程推理。 我们的贡献有三点:(1)将长时程上下文管理表述为状态自适应记忆问题,强调按需访问时间上相距较远的信息,而不只是基于新近程度进行压缩;(2)提出线索—页面记忆架构,将写入时的轻量整合与读取时基于意图、利用保留的原始轨迹页进行的重建解耦;(3)提出独立记忆模型的优化方案,将专家指导监督与 OAT-GRPO 结合,后者是一种记忆动作层面的 RL 目标,通过记忆调用树和以预言机为锚的可恢复性奖励进行信用分配。
2. Method
2.1. Preliminary
In long-horizon agentic reasoning, the information relevant to the next decision is often only a small and implicit subset of the full interaction history. Consider a long-horizon agent interacting with an environment to solve a task instance
在长时程智能体推理中,与下一次决策相关的信息往往只是完整交互历史中一个很小且隐含的子集。 考虑一个与环境交互、以求解任务实例
In practice, each pair
在实践中,每一对
What the agent actually requires at step
智能体在步骤
where
其中,
This perspective suggests a different goal for context management. Instead of approximating
这一视角为上下文管理提出了不同的目标。 我们不以更短的近期历史替代表示来近似
where
其中,
2.2. State-Adaptive Memory (SAM)
Following the formulation above, we instantiate
遵循上述表述,我们使用外部记忆系统 状态自适应记忆(SAM) 来实现
Page-based episodic consolidation. The first step is to determine how the interaction history is consolidated. To preserve the local coherence of reasoning, action, and feedback while keeping the mechanism simple, SAM partitions the trajectory into contiguous pages according to an information budget. Once the recent live context reaches a predefined capacity, SAM groups it into a page
基于页面的情景整合。 第一步是确定如何整合交互历史。 为在保持机制简单的同时,保留推理、动作与反馈之间的局部连贯性,SAM 按照信息预算将轨迹划分为连续的 页面。 一旦近期实时上下文达到预设容量,SAM 就将其归并为一个页面:
where
其中,
For each page
对于每个页面
and the corresponding raw pages are stored in an external page store $\mathcal{P}_t $:
对应的原始页面则存储在外部页面存储 $\mathcal{P}_t $ 中:
The important point is that consolidation in SAM is not irreversible compression. The cue is not meant to replace the page or to function as a self-sufficient substitute for history; it serves as a lightweight handle to that page. In other words, SAM does not flatten past interaction into a single surrogate history, but converts it into a set of navigable memory entries whose underlying trajectory content remains recoverable.
关键在于,SAM 中的整合并非不可逆的压缩。 线索既不旨在替代页面,也不是能够独立充当历史替代品的自足表示;它只是指向该页面的轻量级索引。 换言之,SAM 不会将过去的交互压平为单一的替代历史,而是将其转化为一组可导航的记忆条目,其底层轨迹内容仍可恢复。
Agent-guided cue selection. At step
智能体引导的线索选择。 在步骤
Importantly, this selection is not determined by a hand-crafted retrieval score. The role of the cues is not to replace the agent's judgment about relevance, but to expose a coarse yet persistent map of past interaction. They make it possible for the agent to decide, from its current state, which earlier pages are worth revisiting.
重要的是,这一选择并不由手工设计的检索分数决定。 线索的作用不是替代智能体对相关性的判断,而是提供一幅粗粒度但持久的过去交互地图。 它们使智能体能够从当前状态出发,判断哪些早期页面值得重新查看。
Intent-driven episodic recall. The selected cues identify their underlying pages
意图驱动的情景回忆。 选中的线索指向其底层页面
The recalled content
随后,回忆内容
where
其中,
SAM is state-adaptive primarily in how memory is accessed. Consolidation is intentionally simple and page-based, providing a stable way to turn long trajectories into persistent memory entries. The adaptive component appears at read time: which cues are selected, which pages are revisited, and what information is reconstructed all depend on the agent's current intent. What matters, therefore, is not merely what happened most recently, but which parts of the interaction history are useful for the agent's present state.
SAM 的状态自适应性主要体现在记忆的访问方式上。 整合过程有意采用简单的页面机制,为将长轨迹转化为持久记忆条目提供稳定方式。 自适应部分出现在读取时:选择哪些线索、重新访问哪些页面,以及重建什么信息,都取决于智能体的当前意图。 因此,重要的不仅仅是最近发生了什么,而是交互历史中的哪些部分对智能体当前状态有用。
2.3. Optimization Process of SAM
Optimizing SAM is not simply a matter of training a better summarizer. The memory model must learn a representation whose value is deferred: a cue is useful only if it preserves information that may become important later, and a recall result is useful only if it improves a downstream decision. We therefore optimize SAM as a standalone memory capability, keeping the agent backbone frozen, and follow the same logic as the framework itself: first transfer the desired memory behavior from strong models, then align it with trajectory-level utility in closed-loop interaction.
优化 SAM 并不只是训练一个更好的摘要器。 记忆模型必须学习一种价值延后体现的表示:线索只有保留了日后可能变得重要的信息才有用,回忆结果只有改善了下游决策才有用。 因此,我们将 SAM 作为独立的记忆能力进行优化,冻结智能体骨干模型,并遵循与框架本身相同的逻辑:先从强模型迁移所需的记忆行为,再在闭环交互中使其与轨迹层面的效用对齐。
Expert-guided supervised fine-tuning. We instantiate the memory model with Qwen3.5-9B and bootstrap it from expert traces: leading LLMs (Claude-4.5-Opus and GPT-5.4) act as expert memory models on in-domain queries, and we retain only trajectories that yield correct final answers, providing paired targets for both consolidation (
专家指导的监督微调。 我们以 Qwen3.5-9B 实现记忆模型,并利用专家轨迹进行启动:领先的 LLM(Claude-4.5-Opus 和 GPT-5.4)在域内查询上充当专家记忆模型,我们仅保留最终答案正确的轨迹,为整合(每个页面
OAT-GRPO. Supervised transfer alone is insufficient because memory quality is only partially observable at write time, and vanilla GRPO does not match this structure: it forms its baseline over independent trajectories and assigns a single sparse outcome bit to the whole rollout, rather than to the individual memory actions whose quality we want to optimize. We therefore introduce OAT-GRPO (Oracle-Anchored Tree GRPO), which extends GRPO along two design axes: (i) the rollout is structured as a memory-call tree that exposes a sibling group at every memory action and propagates outcome credit back to each individual memory output; and (ii) at every action node we additionally inject an oracle-anchored reward computed against a committee of frontier models, which densifies the sparse outcome signal and covers regions of the recall space that the on-policy memory model would rarely visit on its own.
OAT-GRPO。 仅靠监督迁移还不够,因为写入时只能部分观测记忆质量,而原始 GRPO 与这一结构并不匹配:它基于彼此独立的轨迹构建基线,并将单一、稀疏的二元结果信号赋给整条 rollout,而非赋给我们希望优化质量的各个记忆动作。 因此,我们提出 OAT-GRPO(Oracle-Anchored Tree GRPO,以预言机为锚的树式 GRPO),沿两个设计维度扩展 GRPO:(i)将 rollout 组织为一棵 记忆调用树,在每个记忆动作处形成兄弟节点组,并将结果信用反向传播到每个独立的记忆输出;(ii)在每个动作节点额外注入相对于前沿模型委员会计算的 预言机锚定 奖励,使稀疏的结果信号更加稠密,并覆盖当前策略记忆模型自身很少访问的回忆空间区域。
Tree-structured outcome reward. Unlike standard agentic RL, where the main reasoning policy is itself the trained model and rollouts can be replayed cheaply with a fixed environment, here the model under training sits behind a tool: the agent calls the memory model multiple times within a single trajectory, and every update changes how every later memory call would have been answered. Naively re-running whole trajectories per gradient step is therefore both wasteful and credit-blind, since the binary task outcome arrives only at the end. The memory-call tree is the natural fix: each time the agent issues a recall, the memory model is branched into
树结构的结果奖励。 在标准智能体 RL 中,主推理策略本身就是待训练模型,且在固定环境下能够以较低成本重放 rollout;与之不同,这里的待训练模型位于 工具背后:智能体在单条轨迹内多次调用记忆模型,而每次更新都会改变后续每次记忆调用原本会得到的回答。 因此,若每个梯度步都简单地重新运行整条轨迹,不仅浪费计算,也无法区分各动作的贡献,因为二元任务结果直到最后才出现。 记忆调用树是自然的解决方式:每当智能体发起回忆,就从记忆模型分出
where
其中,
Oracle-anchored recoverability reward. Outcome credit alone is sparse, high-variance, and coverage-limited, since the on-policy memory model only explores a thin slice of plausible recalls. The deeper difficulty is that no single “golden” recall exists for
预言机锚定的可恢复性奖励。 仅有结果信用仍然稀疏、方差较高且覆盖有限,因为当前策略记忆模型只探索了合理回忆空间中的狭小部分。 更深层的困难在于,对于
OAT-GRPO objective. The two rewards are combined into a per-action signal
OAT-GRPO 目标。 将两种奖励组合为逐动作信号:
where
其中,
and the memory model
记忆模型
where
其中,
3. Experiments
3.1. Datasets
Training data. Our training corpus is built entirely from public agent-trajectory releases: OpenSeeker, 11.7K QA pairs each annotated with a full multi-turn agent trajectory, and OpenResearcher, a complementary deep-research dataset with multi-message tool-augmented traces. Since the two sources are heterogeneous in length and answer reliability, we apply a filtering pass that drops trivially short trajectories and trajectories whose final answer disagrees with the verified gold. The curated subset is used uniformly across training stages.
训练数据。 我们的训练语料完全来自公开的智能体轨迹数据:OpenSeeker,包含 11.7K 个问答对,每个问答对都标注了完整的多轮智能体轨迹;以及 OpenResearcher,这是一个互补的深度研究数据集,提供包含多条消息、由工具增强的轨迹。 由于两个来源在长度和答案可靠性上存在差异,我们进行了一轮过滤,删除过于简短的轨迹,以及最终答案与经核验标准答案不一致的轨迹。 整理后的子集统一用于各个训练阶段。
Evaluation benchmarks. We evaluate on four long-horizon agent benchmarks that stress complementary aspects of memory-intensive reasoning: BrowseComp (long-range web browsing), BrowseComp-ZH (cross-lingual multi-hop search), WideSearch (broad exploration over large search spaces), and HLE (knowledge-intensive scientific reasoning). For evaluation efficiency under limited compute, and following prior work, we randomly sample 200 questions per benchmark on BrowseComp and HLE; BrowseComp-ZH and WideSearch are evaluated on their full sets. Per-benchmark coverage and motivation are detailed in Appendix C.
评估基准。 我们在四个长时程智能体基准上进行评估,分别侧重记忆密集型推理的不同方面:BrowseComp(长程网页浏览)、BrowseComp-ZH(跨语言多跳搜索)、WideSearch(在大规模搜索空间中广泛探索)和 HLE(知识密集型科学推理)。 为在有限算力下提高评估效率,并遵循已有工作,我们在 BrowseComp 和 HLE 上各随机采样 200 道题;BrowseComp-ZH 和 WideSearch 则使用各自的完整测试集。 各基准的覆盖范围及选择动机详见 附录 C。
3.2. Experimental Setup
Models. SAM separates an agent backbone, which drives the reasoning loop, from a memory model, which handles context management. We use two agent backbones spanning complementary regimes: the proprietary GLM-4.7 and the open-source Qwen3.5-35B-A3B. The memory model, instantiated from Qwen3.5-9B and shared across both backbones, is the only component updated during the SFT and RL stages of Section 2.3, and is responsible for both page-level consolidation and intent-driven recall.
模型。 SAM 将驱动推理循环的智能体骨干模型与负责上下文管理的记忆模型分离。 我们使用两个代表互补类型的智能体骨干模型:专有模型 GLM-4.7 和开源模型 Qwen3.5-35B-A3B。 记忆模型以 Qwen3.5-9B 初始化,由两个骨干模型共享,是 第 2.3 节 中 SFT 和 RL 阶段唯一被更新的组件,同时负责页面级整合和意图驱动的回忆。
Tools. The agent operates over a uniform tool interface with five tools: search, visit, scholar, python, and memory, the latter being the SAM recall interface. The first three open-web benchmarks use {search, visit, memory}; HLE additionally enables {scholar, python} for its scientific subset. The toolset remains constant across all context-management baselines on a given benchmark.
工具。 智能体通过统一的工具接口运行,包含五种工具:search、visit、scholar、python 和 memory,最后一种即 SAM 的回忆接口。 前三个开放网页基准使用 {search、visit、memory};HLE 为其科学子集额外启用 {scholar、python}。 在同一基准上,所有上下文管理基线的工具集保持一致。
Baselines. We compare against three groups of methods. (i) Foundation models (OpenAI-o3, GPT-5.4, Claude-4.5-Opus, Kimi-K2.5) are reported as reference numbers from their original releases. (ii) Open-source agent systems (WebThinker, WebSailor, ReSum, IterResearcher, AgentFold) represent the current open-source frontier; per-system memory and workspace designs are summarized in Appendix D. (iii) Context-management baselines share the agent backbone with SAM and form the most controlled comparison: w/o CM retains the entire trajectory in context; discard-tool drops earlier tool responses once they exit a fixed window; recent-k keeps only the last summary replaces the dropped prefix with a rolling summary generated by the agent backbone itself.
基线。 我们与三组方法进行比较。 (i)基础模型(OpenAI-o3、GPT-5.4、Claude-4.5-Opus、Kimi-K2.5)使用各自原始发布中的数值作为参考。 (ii)开源智能体系统(WebThinker、WebSailor、ReSum、IterResearcher、AgentFold)代表当前开源前沿;各系统的记忆与工作空间设计汇总于 附录 D。 (iii)上下文管理基线 与 SAM 共享智能体骨干模型,构成控制变量最严格的比较:w/o CM 将整条轨迹保留在上下文中;discard-tool 丢弃移出固定窗口的早期工具响应;recent-k 仅保留最后 summary 则以智能体骨干模型自身生成的滚动摘要替换被丢弃的前缀。
Inference protocol. Every context-management method, including SAM, runs under an identical inference protocol: a 128K context window with the management routine triggered at 64K, fixed decoding hyperparameters across methods, and a per-query round cap. To reduce sampling variance we report avg@3. Full inference, training, and reward configurations are deferred to Appendix B.
推理协议。 包括 SAM 在内的每种上下文管理方法都使用相同的推理协议:上下文窗口为 128K,在 64K 时触发管理流程,各方法采用固定且一致的解码超参数,并设置每个查询的轮数上限。 为降低采样方差,我们报告 avg@3。 完整的推理、训练和奖励配置见 附录 B。
3.3. Main Results
| Category | Model | CM | B. C. | B. C.-ZH | HLE | WideSea. | Avg. |
|---|---|---|---|---|---|---|---|
| Foundation models | OpenAI-o3† | w/o | 49.7 | 58.1 | 24.9 | 52.6 | 46.3 |
| GPT-5.4 | w/o | 54.9 | – | 35.2 | – | – | |
| Claude-4.5-Opus | w/o | 37.0 | 62.4 | 43.4 | – | – | |
| Kimi-K2.5-1T | w/o | 60.6 | – | 50.2 | 72.7 | – | |
| GLM-4.7 | w/o | 43.5 | 52.5 | 37.2 | 65.4 | 49.4 | |
| Qwen3.5-35B-A3B | w/o | 36.0 | 42.2 | 34.0 | 65.6 | 44.5 | |
| Agent systems | WebThinker-32B† | / | 2.8 | 7.3 | 15.8 | – | – |
| WebSailor-32B† | / | 10.5 | 25.5 | 9.6 | – | – | |
| ReSum-30B† | / | 18.3 | 33.3 | – | – | – | |
| IterResearcher-30B-A3B† | / | 37.3 | 45.2 | 28.8 | – | – | |
| AgentFold-30B-A3B† | / | 36.2 | 47.3 | – | 62.1 | – | |
| Models with CM | GLM-4.7 | discard-tool | 49.0 | 62.5 | 36.5 | 66.3 | 53.6 |
| recent-k | 51.5 | 61.2 | 37.2 | 67.1 | 54.3 | ||
| summary | 53.5 | 59.0 | 37.5 | 68.3 | 54.6 | ||
| SAM (Ours) | 56.5 | 64.2 | 38.2 | 69.2 | 57.0 | ||
| Qwen3.5-35B-A3B | discard-tool | 40.5 | 43.5 | 36.0 | 64.7 | 46.2 | |
| recent-k | 38.2 | 45.0 | 34.2 | 65.3 | 45.7 | ||
| summary | 39.5 | 43.0 | 35.2 | 66.8 | 46.1 | ||
| SAM (Ours) | 42.2 | 46.5 | 37.2 | 69.1 | 48.8 |
Table 1 reports the main results, and we summarize the takeaways in two points.
表1 报告了主要结果,我们将结论概括为两点。
SAM is the strongest context-management method on every backbone. Across the four-benchmark average, SAM beats the best heuristic on each backbone by a clear margin and outperforms the no-management baseline by an even larger one. The lead is largest where the demand on memory is greatest, on BrowseComp and BrowseComp-ZH, indicating that SAM's gains come precisely where heuristic strategies are weakest.
SAM 在每个骨干模型上都是最强的上下文管理方法。 按四个基准的平均成绩计算,SAM 在每个骨干模型上都明显超过最佳启发式方法,并以更大幅度超过不进行上下文管理的基线。 在对记忆要求最高的 BrowseComp 和 BrowseComp-ZH 上,领先幅度最大,表明 SAM 的收益恰好来自启发式策略最薄弱的场景。
The same SAM module generalizes across benchmarks and backbones. A single Qwen3.5-9B memory model, trained once, drives the best score in every backbone–benchmark cell we evaluate, spanning long-range English browsing (BrowseComp), cross-lingual search (BrowseComp-ZH), broad exploration (WideSearch), and knowledge-intensive scientific reasoning (HLE), and on top of two heterogeneous backbones (proprietary GLM and open-source Qwen3.5). The heuristic baselines, in contrast, flip relative ranking across benchmarks (e.g. summary leads BrowseComp on GLM but loses to discard-tool on BrowseComp-ZH), confirming that SAM's improvement is a property of the memory mechanism itself rather than of any benchmark- or backbone-specific coupling.
同一个 SAM 模块能够跨基准、跨骨干模型泛化。 单个只训练一次的 Qwen3.5-9B 记忆模型,在我们评估的每个骨干模型—基准组合中都取得了最佳成绩,涵盖长程英文浏览(BrowseComp)、跨语言搜索(BrowseComp-ZH)、广泛探索(WideSearch)和知识密集型科学推理(HLE),并适用于两个异构骨干模型(专有 GLM 与开源 Qwen3.5)。 相比之下,启发式基线在不同基准上的相对排名会发生反转(例如,在 GLM 上,summary 在 BrowseComp 中领先,却在 BrowseComp-ZH 中落后于 discard-tool),这证实 SAM 的改进源于记忆机制本身,而不是与某个特定基准或骨干模型的耦合。
4. Discussions
4.1. Ablation on Training Stages and Backbone Size
We isolate the contribution of each optimization stage and probe whether the SAM recipe transfers to a larger memory backbone, using GLM-4.7 as the (frozen) agent backbone and inheriting the inference protocol of Section 3.2. Starting from full SAM, we ablate the SFT and OAT-GRPO stages individually, and additionally fine-tune a 27B memory backbone with LoRA (SAM-27B) under otherwise identical settings. As shown in Figure 2 (left), removing either stage causes a consistent drop on every benchmark, confirming that the two stages are complementary rather than redundant: SFT provides a competent prior over consolidation/recall behavior, while OAT-GRPO further sharpens decisions via tree-structured outcome and recoverability rewards. The 27B LoRA variant matches the 9B full-finetune SAM within 0.3 avg., indicating that the gains stem from the SAM mechanism itself and persist when the memory backbone is scaled up.
我们以 GLM-4.7 为冻结的智能体骨干模型,并沿用 第 3.2 节 的推理协议,分离各优化阶段的贡献,同时探究 SAM 方案能否迁移到更大的记忆骨干模型。 从完整 SAM 出发,我们分别消融 SFT 和 OAT-GRPO 阶段,并在其他设置完全相同的条件下,额外使用 LoRA 微调一个 27B 记忆骨干模型(SAM-27B)。 如 图2(左)所示,移除任一阶段都会使每个基准的表现一致下降,证实两个阶段是互补而非冗余的:SFT 为整合与回忆行为提供了良好的先验,而 OAT-GRPO 则利用树结构的结果奖励和可恢复性奖励进一步改善决策。 27B LoRA 变体与 9B 全参数微调 SAM 的平均成绩相差不超过 0.3,表明收益源于 SAM 机制本身,并在记忆骨干模型扩大后依然存在。
| Variant | BC | BC-ZH | HLE | WS | Avg. |
|---|---|---|---|---|---|
| w/o CM | 43.5 | 52.5 | 37.2 | 65.4 | 49.4 |
| SAM | 56.5 | 64.2 | 38.2 | 69.2 | 57.0 |
| Training stage | |||||
| w/o SFT | 55.2 | 63.2 | 37.3 | 67.9 | 55.9 |
| w/o OAT-GRPO | 54.5 | 62.7 | 37.4 | 67.7 | 55.6 |
| Backbone size | |||||
| SAM-27B | 56.6 | 63.9 | 37.8 | 68.3 | 56.7 |
4.2. Is Episodic Recall Necessary?
We test three variants that share SAM's write side but degrade the read side: summary-only (rolling summary, no per-page recall), recency (most-recent pages regardless of intent), and raw-content (raw page contents in place of intent-conditioned snippets). Figure 2 (right) shows all three trail full SAM, with recency barely above the no-memory baseline. Returning raw pages does not close the gap, ruling out lossy consolidation as the sole cause; neither a global digest nor a recency window substitutes for query-conditioned access. Intent-driven recall, rather than consolidation per se, is the principal source of SAM's gains.
我们测试了三个与 SAM 共享写入机制、但弱化读取机制的变体:summary-only(滚动摘要,不进行逐页回忆)、recency(无论意图如何都取最近的页面)和 raw-content(用原始页面内容替代以意图为条件的片段)。 图2(右)显示,三者均落后于完整 SAM,其中 recency 仅略高于无记忆基线。 返回原始页面也无法弥合差距,排除了“有损整合是唯一原因”这一解释;无论全局摘要还是近期窗口,都无法替代以查询为条件的访问。 意图驱动的回忆,而非整合本身,才是 SAM 收益的主要来源。
4.3. Long-Horizon Behavior Analysis
We next examine when and why SAM helps, by zooming in on three orthogonal axes that all stress its long-horizon advantage. Figure 3 reports, on Qwen3.5-35B-A3B, (a) the state of the agent the moment context management is triggered, (b) accuracy as a function of the number of interaction rounds taken to solve a query, and (c) the sensitivity of SAM to the memory page size used during consolidation.
接下来,我们聚焦三个相互独立、都能体现其长时程优势的维度,考察 SAM 何时 有效以及 为何 有效。 图3 基于 Qwen3.5-35B-A3B 报告:(a)上下文管理触发瞬间的智能体状态;(b)准确率随求解查询所需交互轮数的变化;(c)SAM 对整合时所用记忆页大小的敏感性。
(a)不同上下文管理策略的触发时状态。
(b)准确率与交互轮数的关系。
(c)准确率与页面大小的关系。
SAM keeps the agent productive when memory fires. Panel (a) compares the five strategies along three quantities measured at the trigger moment. Among the heuristic baselines, summary is the strongest on tool-call count, confidence, and trigger-time accuracy, while discard-tool and recent-k trail it on every metric. SAM extends the trend further and tops every metric. The accuracy lift exceeds the confidence lift, so the extra activity is not merely louder but also more correct. This contradicts the worry that retrieval-style memory floods the context, intent-driven recall instead lets the agent reach a more decisive state when the threshold is hit.
SAM 使智能体在记忆触发时仍能有效推进任务。 子图(a)根据触发时刻测得的三个量比较五种策略。 在启发式基线中,summary 在工具调用次数、置信度和触发时准确率上表现最强,而 discard-tool 和 recent-k 在所有指标上均落后于它。 SAM 进一步延续这一趋势,在每项指标上都取得最高值。 准确率的提升大于置信度的提升,因此增加的活动并非只是声势更大,而是确实更加正确。 这一结果与“检索式记忆会让上下文过载”的担忧相反:意图驱动的回忆反而使智能体在达到阈值时进入更能作出明确决策的状态。
SAM widens its lead as rounds grow. Panel (b) restricts to the three long-horizon round buckets (21–40, 41–80, >80) on BrowseComp, where context management actually engages. SAM is uniformly above every baseline in every bucket; the SAM-over-summary gap remains visible even past 80 rounds, where summary-only memory begins to lose useful state. The longer the trajectory, the more episodic recall pays off relative to a single rolling summary.
随着轮数增加,SAM 的领先优势扩大。 子图(b)聚焦 BrowseComp 上三个长时程轮数区间(21–40、41–80、>80),这些区间中上下文管理确实会介入。 SAM 在每个区间都高于所有基线;即使超过 80 轮,当仅依赖摘要的记忆开始丢失有用状态时,SAM 相对于 summary 的优势仍然可见。 轨迹越长,情景回忆相对于单一滚动摘要的收益就越明显。
SAM is robust across page sizes. Panel (c) varies the consolidation granularity from 32K to 128K. SAM beats the no-memory baseline at all small-to-medium sizes on both benchmarks; the only failure case is the largest 128K setting on BrowseComp, where each page is large enough to dilute the per-page intent signal. The optimum sits at 32K–64K, small enough to stay semantically focused, large enough to avoid eager consolidation. Together, the three views indicate that SAM's advantage comes from when it intervenes, what it preserves, and how it recalls, not from a narrowly tuned page-size choice.
SAM 对不同页面大小具有稳健性。 子图(c)将整合粒度从 32K 调整到 128K。 在两个基准的所有中小页面设置下,SAM 都超过无记忆基线;唯一的失败情形是 BrowseComp 上最大的 128K 设置,此时每页足够大,以至于稀释了页面内的意图信号。 最优点位于 32K–64K:足够小,能够保持语义聚焦;又足够大,能够避免过早整合。 综合这三个视角可见,SAM 的优势来自它 何时 介入、保留什么 以及 如何回忆,而不是对某个页面大小进行狭窄范围的调优。
5. Related Work
Memory and context management for long-horizon agents. Existing work on keeping the active context manageable largely follows three lines. Action-space approaches let the agent invoke context-editing operations during reasoning, turning context maintenance into a learned skill of the policy. Lossy-surrogate approaches replace history with summaries—via prompted or trained folding operators, inference-time pruning, RL-trained compact internal states, or per-round workspace reconstruction. Retrieval-over-history approaches keep history uncompressed and retrieve from it via dense memory, static intent indices, or learned latent compression. In contrast, SAM treats long-horizon reasoning as state-adaptive memory: a standalone module that consolidates interaction into compact cues while preserving raw trajectory pages, so the cues serve as query-time handles for intent-driven recall, optimized via expert-guided supervision and trajectory-utility-aligned RL, and applied across diverse backbones without retraining them.
长时程智能体的记忆与上下文管理。 现有关于保持活跃上下文可管理的工作主要沿三条路线展开。 动作空间 方法允许智能体在推理过程中调用上下文编辑操作,将上下文维护转化为策略学到的一项技能。 有损替代表示 方法以摘要替换历史,具体形式包括通过提示或训练得到的折叠算子、推理时剪枝、经 RL 训练的紧凑内部状态,以及逐轮工作空间重建。 历史检索 方法保持历史未经压缩,并通过稠密记忆、静态意图索引或学习到的潜在压缩从中检索。 相比之下,SAM 将长时程推理视为 状态自适应 记忆:这是一个独立模块,将交互整合为紧凑线索,同时保留原始轨迹页,使线索成为查询时用于意图驱动回忆的索引;该模块通过专家指导监督和与轨迹效用对齐的 RL 进行优化,并可应用于多种骨干模型,无须重新训练这些骨干模型。
6. Conclusion
We presented State-Adaptive Memory (SAM), a standalone memory framework for long-horizon agentic reasoning. SAM is motivated by a simple observation: as trajectories grow, the main challenge is not merely fitting more history into context, but enabling the agent to access the right past information for its current decision state. To address this, SAM consolidates ongoing interaction into compact memory cues while preserving raw trajectory pages for intent-driven recall. This design allows an agent to recover information from arbitrary stages of its trajectory without retraining the underlying backbone. Experiments across multiple long-horizon benchmarks show that explicit memory modeling provides a simple, general, and effective foundation for improving agentic reasoning. We hope SAM can serve as a useful step toward modular memory systems for increasingly capable agents.
我们提出了状态自适应记忆(SAM),这是一个用于长时程智能体推理的独立记忆框架。 SAM 源于一个简单观察:随着轨迹增长,主要挑战不只是将更多历史塞进上下文,而是使智能体能够根据当前决策状态访问恰当的过去信息。 为此,SAM 将持续发生的交互整合为紧凑的记忆线索,同时保留原始轨迹页,以支持意图驱动的回忆。 这一设计使智能体能够恢复轨迹中任意阶段的信息,而无须重新训练底层骨干模型。 多个长时程基准上的实验表明,显式记忆建模为改善智能体推理提供了简单、通用且有效的基础。 我们希望,SAM 能成为迈向模块化记忆系统的有益一步,为能力不断增强的智能体提供支持。