TL;DR: AI coding agents can cut review failures and token spend when they receive architectural, semantic, and dependency context before writing code, according to Sonar. The economic shift from first-pass success to repeated PR retries makes context delivery a governance issue, not just a productivity feature.
Editorial analysis by NHI Mgmt Group, based on content published by Sonar: “Claude Fable 5's pricing makes Sonar Context Augmentation a potent cost lever”.
By the numbers:
- The study measured 660 Claude Code trials across 33 tasks, showing how codebase quality affects agent token use and file revisits.
- Agents working in cleaner codebases used 7 to 8% fewer tokens per run and revisited files 34% less than agents in messier ones.
- A team merging 200 AI-generated PRs a week can swing between roughly $200 and $800 in output tokens depending on first-pass rate.
Key questions
Q: What breaks when AI code generation lacks project context?
A: Code usually breaks at the integration layer.
Q: Why does repeated PR rework become so expensive with coding agents?
A: Each failed attempt adds another output pass and expands the next prompt with failure context, rewritten files, and fresh instructions.
Q: What do security and engineering teams get wrong about long context windows?
A: They often assume that more context means better judgement, but a long window does not tell the agent which boundaries matter or which rules apply to a specific file.
Practitioner guidance
- Define pre-write context requirements for coding agents Require architectural, semantic, and policy context to be delivered before an agent generates code, rather than after the first failed review.
- Instrument PR retry cost and failure loops Track first-pass merge rate, retry count, and token consumption per pull request so repeated rework becomes visible in programme reporting.
- Constrain third-party dependency selection Route library and package choices through dependency guidance so an agent cannot introduce unvetted or disallowed components by default.
Bottom line: AI coding agents fail more often when they have to infer architecture, dependency rules, and file boundaries from scratch, which turns code review into a rework loop.
Explore further
View Full Forum → | NHI Foundation Course → | Our Services → | Read the full analysis →
Context augmentation is becoming a governance control, not just a developer convenience. AI coding agents are effectively non-human identities with delegated write authority, so the question is whether they receive enough project context to act safely before they touch code. When guidance arrives before generation, the control boundary shifts from review-time rejection to issuance-time direction, which is where modern agent governance has to live.
A few things that frame the scale:
- 92% of organisations expose NHIs to third parties, raising concerns about supply chain security, according to the Ultimate Guide to NHIs.
A question worth separating out:
Q: How should teams govern AI agents that can install dependencies?
A: Treat dependency installation as a privileged action that requires scoped authority, logging, and explicit approval for new packages. The agent should not inherit broad secrets or unrestricted registry access just because it can generate code. If the workflow must install, do it in a constrained environment with secret minimisation and dependency review before merge.
👉 Read our full editorial: Context augmentation is becoming essential for AI coding agents