TL;DR: Coding-agent token usage and cost can be cut by up to 36% by replacing grep-heavy discovery with structural queries that enumerate the real edit set, according to Sonar. The practical lesson is that agentic workflows need navigation-aware controls wherever completeness and context bloat, not build time, drive cost and correctness.
At a glance
What this is: Sonar reports that structural graph navigation can reduce coding-agent tool-call storms and lower token consumption by up to 36% on refactoring tasks.
Why it matters: This matters because agentic development workflows can waste cost and miss edit sites when they rely on text search instead of code structure, which affects correctness as well as efficiency.
By the numbers:
- The article says graph navigation reduced token usage and cost by up to 36% on the best measured refactoring task.
Context
Coding agents often start without a reliable map of the codebase, so they infer change locations by searching text, opening files, and holding more content in context than they really need. That makes the real problem discovery, not editing, and it creates a governance gap when structural dependencies are invisible to character-based search.
Sonar's analysis sits squarely in the overlap between software engineering and agent governance. The identity angle is the agent itself, which behaves like a non-human operator that needs scoped access to code structure, exact edit targets, and guardrails against over-reading and over-searching.
The result is not a general performance story. It is a control story about whether an AI coding agent can enumerate the true edit set, avoid context bloat, and reduce the chance of silent defects when relationships in code are not expressible as simple text matches.
Key questions
Q: What breaks when coding agents rely on grep in multi-language codebases?
A: They miss semantic relationships that text search cannot express, such as owner types, return types, cross-language equivalents, and indirect callers. That leads to broader reads, missed dependencies, and extra CI cycles, all of which increase cost and delay safe delivery.
Q: Why does structural code navigation reduce cost and risk for coding agents?
A: It lets the agent ask for relationships directly, so one query can return the full affected set instead of a long sequence of search and read turns. That lowers token usage while also reducing the odds that a hidden dependency is left unchanged.
Q: What are the signs that an AI coding workflow is wasting effort on discovery?
A: Frequent grep loops, repeated file reads, large context growth, and many search hits that do not translate into actual edit sites all suggest the agent is reconstructing the map by hand. Those are strong indicators that structural navigation would help.
Q: How should teams govern coding agents that can inspect code structure directly?
A: Treat them like non-human operators with scoped intent. Define which queries they may issue, which modules they may touch, and which kinds of refactors require structural enumeration before edits are allowed.
Technical breakdown
Why grep creates tool-call storms in agentic coding
Text search only matches characters, not software relationships. In a coding-agent loop, that means grep can find names, but it cannot tell the agent which class implements which interface, which method is indirectly called, or which symbol reference is the one that actually matters. The agent compensates by reading more files, keeping them in context, and repeating the cycle until it believes it has the full picture. That is why costs rise in two directions at once: more turns and a larger resident context on every later turn.
Practical implication: measure agent search behaviour, not just build time, when you decide whether structural navigation is needed.
Structural code graphs turn discovery into a query problem
A code graph changes the unit of work from text matching to relationship lookup. Nodes represent classes, methods, fields, and other symbols, while edges capture calls, inheritance, implementation, and references across files. Because the graph can answer what implements, what calls, and what references a symbol directly, the agent receives a deduplicated edit set instead of a noisy hit list. That is what makes the approach substitutive rather than additive. If it still sends the agent back to grep, the cost win disappears.
Practical implication: prefer tools that return exact file and line targets, not just symbol names or search hits.
Why completeness matters for correctness, not just cost
The second-order risk is a missed site that still compiles. Some omissions are loud, such as a rename that breaks the build, but indirect behaviour changes can leave a stale location untouched and ship as a silent bug. Structural enumeration matters because it finds locations text search never surfaces, especially when the dependency is implicit rather than textual. In agent terms, that is a governance issue: the tool must reduce both false negatives and unnecessary exploration, or it only shifts cost around without improving outcomes.
Practical implication: treat structural enumeration as a control for missed-edit risk in agentic refactoring, not only as an efficiency feature.
NHI Mgmt Group analysis
Structural navigation is becoming a governance control for coding agents, not a productivity feature. When an agent has to reconstruct code relationships file by file, cost scales with both search turns and resident context, which makes discovery itself the expensive control point. That changes the security and quality conversation around AI-assisted development: the question is whether the agent can be constrained to the right edit surface before it starts reasoning, not whether it can edit once it gets there. Practitioners should treat navigation as part of the agent's operating boundary.
Code graph navigation creates a specific named risk reduction pattern: the tool-call storm collapse. The article shows that graph queries can collapse repeated grep-read cycles into one structural lookup, which reduces token waste and lowers the chance that an agent drifts through irrelevant files. The practical significance is broader than cost. Fewer exploratory reads mean less context exposure, less opportunity for the agent to overfit to noise, and less dependence on manual reconstruction of dependencies. Teams should expect agent governance to move upstream into retrieval design.
This is also an agent identity problem, because the agent is effectively acting as a non-human code operator. Once a coding agent can request structural answers directly, authorisation should be about what it may query and change, not only what repository it can reach. That fits the same governance logic as machine identity control: scope the actor, scope the action, and scope the blast radius. Practitioners should align access and observability around query-level intent, not just broad repository permissions.
Silent-bug prevention is the more important claim, even if it is harder to quantify. The article is strongest when it argues from mechanism: exhaustive structural enumeration can surface edit sites that text search never reveals, which is exactly where agents miss dependencies and ship defects. That means the control question is not whether grep is fast, but whether the workflow can prove it has found every relevant site. Practitioners should make completeness a design criterion for agent tooling.
Agentic code navigation points to a wider market shift toward runtime-aware development controls. The market is moving beyond static prompts and into systems that understand relationships, context, and operational constraints at execution time. For identity and security teams, that is a signal to re-evaluate how non-human actors are observed, authorised, and audited inside software delivery. Practitioners should expect more demand for controls that verify what an agent actually asked for, not just what it was allowed to see.
From our research library:
- Internal repositories are 6x more likely to contain secrets than public ones (32.2% vs 5.6%), contradicting the assumption that private repos are safe, according to the State of Secrets Sprawl 2026.
- Claude Code-assisted commits leaked secrets at a rate of 3.2%, more than double the human-only baseline of 1.5%, with peaks reaching 31 secrets per 1,000 commits in August 2025, according to the State of Secrets Sprawl 2026.
- Read next: AI Agent Identity Security Buyer's Guide
What this signals
Code graph navigation is a retrieval control, not just an ergonomics improvement. Once a coding agent can ask structural questions instead of spraying grep across the repository, the workflow becomes more predictable and less wasteful. That matters because agent governance is increasingly about constraining how non-human operators gather context before they act, not only about approving the final change set.
Tool-call storms are a sign that the agent is compensating for missing structure. When repeated search and read turns become the default path to discovery, the agent is spending budget on reconstruction instead of reasoning. Internal repositories are 6x more likely to contain secrets than public ones (32.2% vs 5.6%), according to the State of Secrets Sprawl 2026, which is a reminder that more reading is not the same as better control.
Structural enumeration should become part of agent risk review. If a workflow cannot prove it found every relevant edit site, then completeness is still an open control gap. For NHI and agentic AI programmes, that means access, observability, and change validation need to be evaluated together rather than as separate engineering concerns.
For practitioners
- Define when structural navigation is mandatory Require graph-based discovery for refactors where the edit set is defined by relationships, not names, especially when a text search returns noisy or incomplete hits.
- Instrument tool-call storms as a control signal Track repeated grep-read cycles, resident context growth, and symbol re-checking as indicators that the agent is compensating for missing structural awareness.
- Bind coding-agent permissions to query scope Limit which repositories, modules, and structural queries an agent can issue so non-human access stays aligned to the intended change surface.
- Use exact edit-target output in agent workflows Prefer tools that return deduplicated file-path and line numbers for every affected site so the agent does not have to re-run text search to find the changes.
- Test for missed-location risk before release Validate refactoring tasks that depend on hidden dependencies with checks designed to catch untouched edit sites, not just compilation success.
Key takeaways
- Coding-agent cost rises when discovery depends on repeated text search and file reads rather than structural understanding of the codebase.
- Graph navigation reduces both search churn and missed-edit risk by returning the relationships and locations an agent needs in one pass.
- For non-human coding workflows, completeness of discovery is a governance control, not an optional efficiency tweak.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10, OWASP Non-Human Identity Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST AI RMF sets the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | ASI03 — Identity & Privilege Abuse | Coding agents act as non-human operators that need scoped query and edit authority. |
| Recommendation — Scope agent queries and edit permissions so structural navigation stays within approved intent. | ||
| OWASP Non-Human Identity Top 10 | NHI-05 — Overprivileged NHI | Overbroad repository access lets coding agents inspect far more code than needed for a task. |
| NHI-10 — Human Use of NHI | Developers are increasingly using coding agents as non-human operators inside delivery pipelines. | |
| Recommendation — Restrict agent repository access to the smallest code surface needed for the change. Treat coding agents as governed non-human identities with explicit task boundaries and auditing. | ||
| MITRE ATT&CK | TA0007 — Discovery | The core problem is inefficient discovery of affected code paths and dependencies. |
| Recommendation — Map repeated search-and-read behavior to discovery activity and reduce unnecessary exploration. | ||
| NIST AI RMF | MANAGE — AI Risk Management and Controls | The article concerns how to manage AI agent behavior, cost, and error risk in production workflows. |
| Recommendation — Use managed AI controls to constrain agent context gathering and validate completeness before edits. | ||
Key terms
- Structural Code Navigation: A method of finding code by relationships instead of by text matches. It uses symbol and dependency links such as calls, implementations, and references to identify the exact files and lines that need change, which is more reliable than grep when the edit set is defined by code structure.
- Tool-Call Storm: A repeated sequence of search, read, and inference turns that an agent uses to reconstruct code relationships manually. It increases token consumption, inflates resident context, and often signals that the agent lacks a structural view of the codebase.
- Resident Context: The working set of information an AI model carries across turns while completing a task. When too many files are opened and retained, resident context becomes a hidden cost driver because every later step must process that accumulated material.
- Non-Human Code Operator: An AI system that can inspect, reason about, and change software within a delivery workflow. The term matters because it behaves like an operational actor with scope, permissions, and audit needs, even when a human still approves the final release.
Deepen your knowledge
The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, agentic AI identity, and machine identity security. It is designed for practitioners who need to govern non-human actors as part of a broader identity security programme.
Published by the NHIMG editorial team on August 18, 2026.
Updated on October 12, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org