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

代码智能体需要多少静态结构?关于确定性锚定的研究

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

Beihang University(北京航空航天大学)

Zhihao Lin, Mingyi Zhou, Yizhuo Yang, Li Li

AI总结:

研究轻量级静态分析(如调用图、继承层次)作为确定性锚定,通过注入结构注释提高代码智能体导航的可复现性和稳定性,发现锚定效果依赖粒度与仓库特性。

摘要:

基于LLM的代码智能体通过关键词搜索导航仓库,但忽略了定义软件实际工作方式的结构关系,如调用图、继承层次和配置依赖。这使得智能体导航具有随机性,难以跨运行复现。我们研究轻量级静态分析是否能为这些智能体提供确定性锚定:以纯文本注释形式注入稳定的结构事实,约束概率探索并使导航更可预测。从强基线OpenAI的Codex出发,我们系统性地注入不同粒度的结构注释,并测量其对定位、轨迹行为和运行间稳定性的影响。我们的研究识别出所谓的确定性锚定效应:静态结构帮助不大是因为让智能体“更聪明”,而是因为使导航更规范且可复现。三个观察支持这一发现:(1) 锚定有效:轻量级调用/继承拓扑提升了函数级定位(Func@5 +2.2个百分点)并缩短了轨迹(-1.6交互轮次);(2) 锚定对规模敏感:最佳粒度和方向性取决于仓库特征,更密集的语义显示收益递减,而枢纽密集的项目受益于仅显示“谁调用我”而无前向边的反向链接;(3) 锚定稳定化:标签将链接跟随率从0.15-0.18提升至0.21-0.24,运行间方差大致减半,并在中等规模仓库上提升单次运行可靠性(Pass@1 +3.4个百分点),代价是约10%的额外输入令牌。这些观察建议实用指南:中等项目默认使用轻量级拓扑,大型仓库剪除前向边,密集标签保留给隐式依赖情况。

英文摘要:

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.

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

↑