How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring
Abstract
LLM-based code agents navigate repositories through keyword search but lack access to the structural relationships, such as call graphs, inheritance hierarchies, and configuration dependencies, that organize software systems. This limitation can make agent navigation stochastic and difficult to reproduce across runs. We investigate whether lightweight static analysis can provide deterministic anchors: stable structural facts injected as plain-text comments to guide probabilistic exploration. Starting from Codex as a strong grep-first baseline, we systematically vary the granularity and directionality of structural annotations and measure their effects on localization, navigation behavior, and run-to-run stability. Lightweight call and inheritance topology improves function-level localization by 2.2 percentage points at Func@5 and shortens trajectories by 1.6 interaction rounds. The optimal annotation design depends on repository scale: denser semantic annotations provide diminishing returns, while hub-heavy projects benefit from inverse-only links that avoid excessive forward-edge noise. Structural tags also increase the link-following rate from 0.15–0.18 to 0.21–0.24, reduce run-to-run variance by roughly half, and improve single-run reliability by 3.4 percentage points at Pass@1 on medium-scale repositories, at the cost of approximately 10% more input tokens. These results show that static structure improves code-agent navigation by making exploration more disciplined and reproducible. They support a topology-first design: use lightweight bidirectional structure for medium-scale repositories, prune forward edges in hub-heavy repositories, and reserve dense annotations for tasks involving implicit dependencies.
// Source
Authors: Zhihao Lin, Mingyi Zhou, Yizhuo Yang, Li Erran Li
Institutions: Beihang University