How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring
Zhihao Lin, Mingyi Zhou, Yizhuo Yang, Li Li
摘要
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: ❶ Anchoring works: lightweight call/inheritance topology improves function-level localization (+2.2pp Func@5) and shortens trajectories (-1.6 interaction rounds); ❷ Anchoring is scalesensitive: 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; ❸ 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. Code and traces are available in our repository: https://github.com/mathieu0905/Code-Anchor.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
脉络
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering 引用了 SWE-bench: Can Language Models Resolve Real-world Github Issues?
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering 引用了 Executable Code Actions Elicit Better LLM Agents
- Executable Code Actions Elicit Better LLM Agents 引用了 Toolformer: Language Models Can Teach Themselves to Use Tools
它引用的 Paper19
- Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksPatrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni 等NeurIPS 2020 · 19,162 次引用
- Toolformer: Language Models Can Teach Themselves to Use ToolsTimo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu 等NeurIPS 2023 · 5,989 次引用
- SWE-bench: Can Language Models Resolve Real-world Github Issues?Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao 等ICLR 2024 · 2,082 次引用
- SWE-agent: Agent-Computer Interfaces Enable Automated Software EngineeringJohn Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret 等NeurIPS 2024 · 2,059 次引用
- Executable Code Actions Elicit Better LLM AgentsXingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang 等ICML 2024 · 436 次引用
相关 Paper
- LocAgent: Graph-Guided LLM Agents for Code LocalizationZhaoling Chen, Robert Tang, Gangda Deng, Fang Wu 等ACL 2025
- One Size Does Not Fit All: Revisiting Code Context Engineering for Repository-Level Code GenerationYichen Li, Qiye Lin, Yun Peng, Zhihan Jiang 等FSE 2026
- Let the Comments Speak: A Multi-Agent Framework based on Large Language Model for Comment-Guided Code RefactoringZixuan Wang, Wutong Yu, Deyu ZhouACL Findings 2026
- CODESTRUCT: Code Agents over Structured Action SpacesMyeongsoo Kim, Chao-Chun Hsu, Dingmin Wang, Shweta Garg 等ACL 2026
- Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding AgentsYutong Cheng, Haifeng Chen, Wenchao Yu, Xujiang Zhao 等ICML 2026
