Join our Newsletter — 33% off our NHI Course

Notifications
Clear all

AI coding agents in large repos: what the navigation tax changes


(@nhi-mgmt-group)
Member Moderator
Joined: 1 year ago
Posts: 19841
Topic starter  

TL;DR: AI coding agents in large repositories can burn 156 million context tokens and peak at 459k tokens on a single ~800-line pull request, according to Sonar’s analysis, because every blind read is re-billed across hundreds of turns. The key implication is that graph-based code navigation, not grep, becomes the control that limits cost and missed call sites.

NHIMG editorial — based on content published by Sonar: how AI coding agents pay a navigation tax when context windows break

By the numbers:

  • The session included 512 model round-trips and 152.8 million cache-read tokens, according to Sonar’s measured PR data.

Questions worth separating out

Q: How should security teams limit context sprawl when AI coding agents work in large repositories?

A: Use semantic retrieval instead of broad file reads, and measure how much context each task carries forward.

Q: Why do AI coding agents become expensive in long-running sessions?

A: Because each new turn re-sends prior conversation state, so earlier file reads are paid for again and again.

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.

Practitioner guidance

  • Implement semantic repository navigation for code agents Replace grep-first workflows with graph-backed retrieval that returns the exact symbol, owner type, callers, and related documentation needed for the task.
  • Measure context footprint per change Track round-trips, peak context size, cache-read tokens, and the ratio of useful lines to file lines read.
  • Constrain long-lived conversation state Set policies for when sessions should be compacted or restarted so that unnecessary file reads do not remain resident for hundreds of turns.

What's in the full article

Sonar's full analysis covers the operational detail this post intentionally leaves for the source:

  • The measured trace data behind the 156 million context-token example, including round-trip counts and cache-read breakdowns.
  • The implementation logic behind SemSitter’s Unified Dependency Graph and how it keeps the repository model updated.
  • The detailed comparison between grep-based navigation and semantic graph queries across code, documentation, and languages.
  • The PR-level examples showing where call-site resolution and cross-language linking changed the agent’s behaviour.

👉 Read Sonar’s analysis of why AI coding agents pay a navigation tax in large repos →

AI coding agents in large repos: what the navigation tax changes?

Explore further

View Full Forum →  |  NHI Foundation Course →



   
Quote
(@mr-nhi)
Member Moderator
Joined: 4 months ago
Posts: 19434
 

Semantic navigation is the missing governance layer for AI coding agents. The article shows that the problem is not model reasoning but how the agent finds the right code, documentation, and cross-language relationships. That makes repository navigation an identity and access problem in practice, because the agent must be constrained to the minimum context needed for each task. For practitioners, the control objective is to reduce uncontrolled context exposure, not just improve search quality.

A question worth separating out:

Q: How can teams tell whether an AI coding workflow is using too much context?

A: Watch for high peak token counts, many model round-trips, repeated whole-file reads, and a large gap between the final diff size and the context carried through the session. If those metrics keep rising, the workflow is spending more on navigation than on actual change work.

👉 Read our full editorial: AI coding agents pay a navigation tax when context windows break



   
ReplyQuote
Share: