让大模型智能记忆推理步骤间的依赖关系,提升长对话表现。
ContextWeaver: Selective and Dependency-Structured Memory Construction for LLM Agents

- 用图结构记录每步推理的依赖关系,精准定位关键信息
- 在SWE-Bench上比滑动窗口基线提升通过率,减少推理步数
- 适合需要多步逻辑推理的工具调用类模型应用
大语言模型代理在长上下文交互中常因上下文管理不当而失效。传统滑动窗口或提示压缩会丢失早期关键信息;现有基于检索的记忆系统虽能召回相关内容,却忽视多步推理所需的因果与逻辑结构。本文提出ContextWeaver,一种选择性且依赖结构化的记忆框架,将代理的交互轨迹组织为推理步骤图,并选择性保留未来动作所需上下文。该框架支持:(1)基于依赖关系构建与遍历,连接当前步骤与其依赖的前期步骤;(2)紧凑的依赖摘要,将根到节点的推理路径压缩为可复用单元;(3)轻量级验证层,融合执行反馈。在SWE-Bench Verified和Lite基准上,ContextWeaver在pass@1指标上优于滑动窗口基线,同时减少推理步数与令牌使用量。结果表明,建模逻辑依赖可为使用工具的LLM代理提供稳定、可扩展的记忆机制。
原文摘要 · Abstract (English)
Large language model (LLM) agents often struggle in long-context interactions. As the agent accumulates more interaction history, context management approaches such as sliding window and prompt compression may omit earlier structured information that later steps rely on. Recent retrieval-based memory systems surface relevant content but still overlook the causal and logical structure needed for multi-step reasoning. We introduce ContextWeaver, a selective and dependency-structured memory framework that organizes an agent's interaction trace into a graph of reasoning steps and selects the relevant context for future actions. Unlike prior context management approaches, ContextWeaver supports: (1) dependency-based construction and traversal that link each step to the earlier steps it relies on; (2) compact dependency summarization that condenses root-to-step reasoning paths into reusable units; and (3) a lightweight validation layer that incorporates execution feedback. On the SWE-Bench Verified and Lite benchmarks, ContextWeaver improves performance over a sliding-window baseline in pass@1, while reducing reasoning steps and token usage. Our observations suggest that modeling logical dependencies provides a stable and scalable memory mechanism for LLM agents that use tools.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。