# 代码智能体需要多少静态结构？确定性锚定效应研究

- 来源：HuggingFace Daily Papers（社区热门论文）
- 发布时间：2026-06-25 08:00
- AIHOT 分数：58
- AIHOT 链接：https://aihot.virxact.com/items/cmqzhlkh701qtsltjylsu6a6f
- 原文链接：https://arxiv.org/abs/2606.26979

## AI 摘要

基于LLM的代码智能体依赖关键词搜索导航仓库，但缺失调用图、继承关系等结构信息，导致导航随机且难以复现。研究以OpenAI Codex为基线，向提示词注入不同粒度的轻量级静态结构注释，发现确定性锚定效应：函数级定位Func@5提升2.2个百分点，交互轮次减少1.6轮；链接跟随率从0.15–0.18升至0.21–0.24，单次运行Pass@1提升3.4个百分点，但输入token增加约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.
