ContextWeaver:面向LLM代理的选型与依赖结构化记忆构建
ContextWeaver: Selective and Dependency-Structured Memory Construction for LLM Agents
AI总结:
本文提出ContextWeaver,通过构建推理步骤图谱,实现LLM代理的记忆选择与依赖结构化,提升长上下文交互性能,减少推理步骤与token消耗。
摘要:
大型语言模型(LLM)代理在长上下文交互中常面临挑战。随着交互历史积累,滑动窗口和提示压缩等上下文管理方法可能遗漏后续步骤依赖的结构化信息。本文引入ContextWeaver,一种选型且依赖结构化的记忆框架,将代理的交互轨迹组织为推理步骤图谱,并为未来行动选择相关上下文。与以往方法不同,ContextWeaver支持依赖构建与遍历、依赖摘要以及轻量级验证层。在SWE-Bench Verified和Lite基准上,ContextWeaver在pass@1指标上优于滑动窗口基线,同时减少推理步骤和token使用。我们的观察表明,建模逻辑依赖为LLM代理提供了一种稳定且可扩展的记忆机制。
英文摘要:
Large language model (LLM) agents often struggle in long-context interactions. As the history grows, sliding windows and prompt compression may drop earlier information that later steps rely on. Retrieval-based memory systems surface relevant content but still overlook the causal and logical dependencies between steps. 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. ContextWeaver supports (1) dependency-based construction and traversal that link each step to the earlier steps it relies on; (2) compact dependency summaries of the reasoning paths; and (3) a lightweight validation layer that incorporates execution feedback. On five software-engineering and terminal benchmarks with a fixed budget per task, ContextWeaver improves the resolve rate over a sliding-window baseline on all five, with a significant gain when pooled across benchmarks, while using 13-18% fewer agent steps. It also performs favorably against alternative context-management approaches, with the largest gains on long-horizon repository tasks. On SWE-Bench Pro, ContextWeaver raises the resolve rate from 66.5% to 72.6%, with significant improvements across all three model backbones. The improvement also holds when the sliding window's budget is raised to cover the summary cost.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。