代码代理需要多少静态结构?确定性锚点研究

How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring

精选理由

这篇论文用实验告诉你:给代码代理加一点调用图注释,定位准了2.2%,交互少了1.6轮,运行还更稳定。比堆更多上下文管用。

AI 摘要

本研究系统性地向Codex代码代理注入不同粒度的静态结构注释(如调用图、继承拓扑),发现轻量级拓扑可将函数级定位准确率(Func@5)提升2.2个百分点,并减少1.6轮交互。静态锚点使代理的链接跟随率从0.15-0.18提升至0.21-0.24,单次运行通过率(Pass@1)增加3.4个百分点,同时运行方差减半。但代价是增加约10%的输入token,且稠密语义存在边际效益递减。研究建议中等规模项目默认使用轻量级拓扑,大型仓库裁剪前向边,隐式依赖场景才采用密集标签。

原文 · arXiv: OpenAI

How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring

LLM-based code agents navigate repositories through keyword search but miss the structural relationships, such as call graphs, inheritance hierarchies, and configuration dependencies, that define how software actually works. This makes agent navigation stochastic and difficult to reproduce across runs. We investigate whether lightweight static analysis can provide deterministic anchors for these agents: stable structural facts injected as plain-text comments that constrain probabilistic exploration and make navigation more predictable. Starting from a strong baseline, Codex from OpenAI, we systematically inject varying granularities of structural annotations and measure their effects on localization, trajectory behavior, and run-to-run stability. Our study identifies what we call the deterministic anchoring effect: static structure helps less by making agents "smarter" and more by making their navigation disciplined and reproducible. Three observations support this finding: (1) Anchoring works: lightweight call/inheritance topology improves function-level localization (+2.2pp Func@5) and shortens trajectories (-1.6 interaction rounds); (2) Anchoring is scale-sensitive: the optimal granularity and directionality depend on repository characteristics, where denser semantics show diminishing returns and hub-heavy projects benefit from inverse-only links that expose "who-calls-me" without forward edges; (3) Anchoring stabilizes: tags raise link-following rate from 0.15-0.18 to 0.21-0.24, roughly halve run-to-run variance, and improve single-run reliability (Pass@1 +3.4 pp) on medium-scale repositories, at the cost of roughly 10% more input tokens. These observations suggest practical guidelines: default to lightweight topology on medium projects, prune forward edges in large repositories, and reserve dense tags for implicit-dependency cases.