arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.22087cs.CL
收藏

上下文作为工具:长周期SWE代理的上下文管理

Context as a Tool: Context Management for Long-Horizon SWE-Agents

Beihang University(北航大学);Manchester(曼彻斯特);Ubiquant

Shukai Liu, Jian Yang, Bo Jiang, Yizhi Li, Jinyang Guo, Xianglong Liu, Bryan Dai

AI总结:

CAT通过整合上下文管理工具,提升SWE代理的长周期推理能力,实验表明其在SWE-Bench-Verified上达到57.6%的解决率,显著优于现有方法。

摘要:

基于大语言模型的代理近年来在需要与仓库级代码库进行长周期交互的现实软件工程(SWE)任务中展现了强大的潜力。然而,大多数现有代理依赖于只追加的上下文维护或被动触发的压缩启发式方法,这往往导致上下文爆炸、语义漂移和长周期交互中的推理退化。我们提出了CAT,一种新的上下文管理范式,将上下文维护提升为一个可调用的工具,整合到代理的决策过程中。CAT正式化了一个结构化的上下文工作区,包括稳定的任务语义、压缩的长期记忆和高保真的短期交互,并使代理能够主动将历史轨迹压缩成可操作的摘要,在适当的时间节点。为了支持SWE代理的上下文管理,我们提出了一种轨迹级监督框架CAT-GENERATOR,基于一个离线数据构建管道,将上下文管理动作注入到完整的交互轨迹中。使用该框架,我们训练了一个上下文感知模型SWE-Compressor。在SWE-Bench-Verified上的实验表明,SWE-Compressor达到了57.6%的解决率,并显著优于ReAct基于的代理和静态压缩基线,同时在受约束的上下文预算下保持稳定和可扩展的长周期推理。

英文摘要:

Agents based on large language models have recently shown strong potential on real-world software engineering (SWE) tasks that require long-horizon interaction with repository-scale codebases. However, most existing agents rely on append-only context maintenance or passively triggered compression heuristics, which often lead to context explosion, semantic drift, and degraded reasoning in long-running interactions. We propose CAT, a new context management paradigm that elevates context maintenance to a callable tool integrated into the decision-making process of agents. CAT formalizes a structured context workspace consisting of stable task semantics, condensed long-term memory, and high-fidelity short-term interactions, and enables agents to proactively compress historical trajectories into actionable summaries at appropriate milestones. To support context management for SWE-agents, we propose a trajectory-level supervision framework, CAT-GENERATOR, based on an offline data construction pipeline that injects context-management actions into complete interaction trajectories. Using this framework, we train a context-aware model, SWE-Compressor. Experiments on SWE-Bench-Verified demonstrate that SWE-Compressor reaches a 57.6% solved rate and significantly outperforms ReAct-based agents and static compression baselines, while maintaining stable and scalable long-horizon reasoning under a bounded context budget.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑