arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.34763cs.SEcs.AI
收藏

上下文的物理成本:编码智能体的质量约束资源核算

The Physical Cost of Context: Quality-Constrained Resource Accounting for Coding Agents

University of California, San Diego(加利福尼亚大学圣地亚哥分校);University of Massachusetts Amherst(马萨诸塞大学阿默斯特分校)

Zhongming Yu, Yitong Ma, Hengjia Yu, Boqin Yuan, Xiangye Lin, Hejia Zhang, Jishen Zhao

AI总结:

该研究针对编码智能体提出质量约束的资源核算方法,发现缩短轨迹可节省物理工作,但编辑可复用历史会增加工作,Eager 策略能有效降低调用次数与能耗。

摘要:

编码智能体在每次模型调用时会发送不断增长的上下文,而上下文策略通常仅根据其节省的提示词数量来评判。已执行的工作还取决于调用次数和前缀复用:缓存运行时仅在最长缓存前缀之后预填充 token。因此,较短的提示词若重写缓存历史,可能会产生更高的成本。我们的质量门控协议将已执行的预填充拆分为逻辑提示词减去复用前缀,并测量 KV 驻留时间、时间和能耗。在从 SWE-rebench V2 衍生的 450 个定位案例中,预加载 10 个检索块(Eager)并添加锚定历史压缩(Compact)均通过了 5 个百分点的非劣效门限。在另一项包含 900 个单元的研究中,与按需搜索(Grep)相比,Eager 将模型调用次数减少了 35.7%,GPU 能耗代理值降低了 33.2%;Compact 未进一步节省。启用前缀缓存后,Eager 的提示词量仅略有增加(+8.3%;其 95% 置信区间包含零),但未缓存的预填充减少了 67.7%。删除历史会将 token 节省转化为额外工作。在针对 100 个 SWE-bench Verified 实例的 mini-SWE-agent 测试中,仅保留最后 5 个观测值(Mask-5)使 Eager 的提示词量减少了 33.3%,但每个任务损失了 135900 个可复用 token,未缓存的预填充增加了 608.5%,能耗代理值增加了 125.6%,且该策略未通过质量门限。因此,策略可通过缩短轨迹节省物理工作,也可通过编辑可复用历史使物理工作成倍增加。

英文摘要:

Coding agents resend a growing context on every model call, and context policies are usually judged by the prompt tokens they save. Executed work also depends on call count and prefix reuse: a caching runtime prefills only the tokens after the longest cached prefix. A shorter prompt can therefore cost more if it rewrites cached history. Our quality-gated protocol splits executed prefill into logical prompt minus reused prefix and measures KV residency, time, and energy. On 450 localization cases derived from SWE-rebench V2, preloading ten retrieved blocks (Eager) and adding anchored history compaction (Compact) both pass a five-point non-inferiority gate. In a separate 900-cell study, Eager cuts model calls by 35.7% and the GPU-energy proxy by 33.2% against on-demand search (Grep); Compact saves nothing further. Enabling prefix caching leaves Eager's prompt volume similar (+8.3%; its 95% CI spans zero) but cuts its uncached prefill by 67.7%. Deleting history can turn a token saving into extra work. With mini-SWE-agent on 100 SWE-bench Verified instances, keeping only the last five observations (Mask-5) cuts Eager's prompt volume by 33.3% but loses 135.9k reusable tokens per task. Uncached prefill rises by 608.5%, the energy proxy by 125.6%, and the policy misses the quality gate. Policies thus save physical work by shortening the trajectory and can multiply it by editing reusable history.

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

↑