On this page
1.7M-Line Codebase with AI Agents: What Scales and Breaks
tl;dr
Context strategy, not model choice, determines whether AI agents help or hurt at million-line scale. Standard grep-based tools break above 400,000 lines, while index-backed retrieval uses 3.6x fewer tokens and scores higher on the same model.
A 1.7-million-line codebase sits in the zone where standard AI tooling starts to fail systematically. Research from CodeScaleBench shows that agents relying only on local file tools — grep, read, glob — begin to struggle once a repository exceeds roughly 400,000 lines, and the penalty compounds between 400K and 2M lines where code-intelligence tools flip from a −0.080 reward delta to a +0.259 advantage across 1,281 scored runs on 40+ large codebases 1.
Why Does a 1.7M-Line Codebase Break Standard AI Tooling?
The failure mode isn’t about model intelligence — it’s about retrieval architecture. On a 1.5-million-line repository, an index-backed research agent consumed 767K tokens per task versus 2.80M tokens for grep-and-file-read access, while scoring 12.8 points higher on the same model 2. That’s a 3.6x token difference for better results. The problem compounds because local vector indexes (the approach Cursor uses) go stale as engineers push changes; one senior engineer documented a regression caused by Cursor’s Composer seeing only 3 of 14 matches for a deprecated wrapper because the index hadn’t updated 3. Meanwhile, agentic file-system search (Claude Code’s approach) stays fresh but burns tokens and latency on every turn.
The 400K-line threshold isn’t arbitrary. Below it, grep typically works fine and adding code-intelligence tools actually adds overhead. Above it, the reward delta flips positive because the relevant context is too dispersed for linear search to find reliably 1. A 1.7M-line codebase sits squarely in this range, which means your context strategy — not your model choice — determines whether agents help or hurt.
How Do the Major Tools Compare on Pricing at Scale?
Seat price is now a floor, not the full bill. Since June 1, 2026, GitHub moved every Copilot plan to usage-based billing: each seat includes a monthly AI credit allotment equal to the seat price, and everything beyond it is metered at API rates 4. Cursor made the same shift a year earlier. The new GitHub Enterprise model goes further — Copilot is now included for every licensed user at no separate seat cost, with AI usage metered from the first request against an enterprise budget 5. Code completion keeps working even when the budget is exhausted, but Copilot Chat, code review, and cloud features require available budget 5.
| Tool | Seat Cost (50 engineers/year) | Usage Model | Context Approach |
|---|---|---|---|
| GitHub Copilot Business | $11,400 6 | $19/seat/mo credit pool, then API rates | GitHub-native, workflow-integrated |
| GitHub Copilot Enterprise | $36,000 7 | $39/seat/mo credit pool + $21 GitHub Enterprise Cloud, then API rates | Deep GitHub integration, IP indemnity |
| Cursor Teams | ~$24,000 6 | Included usage allotment, then billed in arrears at API rates | Local vector index, agentic UX |
| Claude Code (Team Premium) | — | Prepaid usage credits with spend limits | Agentic file search, no persistent index |
For a 50-engineer team, seat fees alone range from $11,400/year on Copilot Business to $36,000/year on Copilot Enterprise (which requires GitHub Enterprise Cloud at $21/user/month on top of the $39 Copilot seat) 7. But usage often dwarfs seats. Anthropic reports Claude Code usage across enterprise deployments averages $150–$250 per developer per month — $7,500–$12,500 for 50 engineers — with 90% of users below $30 per active day 8. Model choice moves this significantly: Opus 5.5 costs twice as much as Sonnet 5.5 per million tokens 8.
What Context Strategy Actually Works at This Scale?
The winning pattern at million-line scale is structured retrieval over raw context dumps. A controlled experiment on PicoScenes, a 1.52-million-line industrial codebase, found that an expert-AI hybrid approach — where humans handle architectural design and LLMs implement modules — saved 68.3% of feature-implementation time, reduced mean cyclomatic complexity by 28.2%, cut the defect rate by 50%, and reduced CPU load by 25% 9. The key was routing tasks to the smallest relevant directory, keeping root context files as maps, and moving repeatable expertise into skills 10.
Three layers work together: instruction files (CLAUDE.md, AGENTS.md, .cursor/rules) for commands and conventions; search matched to the question — grep for exact identifiers, semantic search for “where do we handle X,” call graphs for “who calls this”; and MCP servers for code outside the current checkout 2.
This mirrors what we’ve seen in how AI coding agents build context — the bottleneck isn’t model capability but context decay, and the fix is repo-persistent context engineering, not bigger windows. Structured retrieval beats raw repo dumps regardless of window size.
Where Does the Real Bottleneck Shift When Agents Generate Code?
The comprehension bottleneck is real and measured. A Coleman Parkes/Undo survey of 300 senior engineering leaders found that 35% of AI-generated code reaches production before the team fully understands it, 80% say coding agents struggle to solve difficult problems in complex codebases, and 79% say the overall release cycle is “no faster than before” because debugging and comprehension now consume more time than generation saved 11. Teams spend an average of 9.8 hours per week producing code but 16.9 hours debugging — 42% of the working week 11.
This matches the pattern we documented in AI agents for large-scale refactoring: only a small fraction of frontier-model runs complete whole-repository refactors without breakage, and success depends far more on automated behavior-level verification and AST-aware tooling than on the underlying model. The generation speedup is real — 68.3% time savings on implementation 9 — but it moves the constraint from writing to reviewing. Anthropic’s own monorepo went from ~2,500 merged changes/day in May 2026 to over 30,000/day by September, with ~25 million CI checkouts daily, forcing them to replace Git with an in-house system called Scion 12. Their review target: most PRs merge with at most one human in the loop, with no increase in reverts or incidents 13.
Sourcegraph’s CEO argues that AI agents are destabilizing massive legacy codebases by introducing inconsistent standards, duplicate code, fragile inter-service dependencies, and vulnerabilities faster than teams can review them 14. Their batch-changes agent can commit changes across hundreds or thousands of repositories from a single prompt — a capability that amplifies both the speed and the risk 14. The Mercari case study found 80 additional configuration vulnerabilities beyond the two originally known 14.
How Are Teams Handling the Infrastructure Strain?
The infrastructure strain shows up in three places: source control, CI, and review. Anthropic’s migration to Scion moved repository operations server-side with content-addressed storage and tiered caches, achieving cache-hit rates above 99% and checkout speedups of two orders of magnitude for CI 12. GitLab’s Next Generation Source Code Management (in private beta) lets agents query the repository server-side for exactly what each task requires, delivering up to 50x faster task execution and up to 1000x less network traffic 15. GitLab Orbit, a context graph for the entire software lifecycle, shows agents responding up to 11x faster with 4.5x fewer tokens 15.
For teams not building custom VCS, the practical moves are: worktree isolation for parallel agents, explicit file ownership, test gates before merge, and review rituals that treat agent output as untrusted until verified 10. Atlassian’s Code Context, which indexes codebases into a Teamwork Graph, reports 44% more accurate agent results with 48% fewer tokens 16.
Security adds another dimension. Researchers compromised OpenAI’s internal GitHub monorepo in under 72 hours via a chain from a Discourse forum RCE through SSO misconfiguration to a Codex environment 17. Monorepos make agents more useful but compromised accounts harder to contain — broad, persistent agent access raises the stakes 17.
What Should Your 50-Engineer Team Budget For?
Based on the projection derived from current pricing, a 50-engineer team on GitHub Copilot Enterprise pays $36,000/year in seat fees alone (50 × ($39 Copilot Enterprise + $21 GitHub Enterprise Cloud) × 12), before any metered AI usage overage beyond the included credit pool 7. Cursor Teams at $30–$40/user/month seat cost plus usage runs similar or higher. The cheapest seat does not tell you which rollout is cheapest 8.
The decision framework I use with teams: compare tools by cost per merged change, not per seat. Seat cost is a floor; the real bill is determined by usage, context freshness, and whether your review infrastructure can absorb agent-scale output. If your team already runs on GitHub and Microsoft, Copilot Business at $19/seat with its included credit pool is the logical baseline — add Claude Code on a metered plan for the minority doing agentic work, and put a hard budget cap on both 7. If you’re standardizing on one editor and need deeper agent tooling for multi-file, parallel work, Cursor’s ~2x seat premium pays for itself only if the agentic UX reduces context-retrieval tokens enough to offset the difference 6.
For a 1.7M-line codebase specifically: invest in an index-backed context layer (MCP server or code graph) that answers “who calls this” and “where is X implemented” without dumping millions of tokens into prompts. Then budget for the review bottleneck: more CI capacity, automated behavior verification, and a human-owned review loop that treats agent diffs as guilty until proven innocent.
The tools that win long-term integrate transparently into existing workflows rather than demanding workflow rewrites. GitHub Copilot wins on compliance and workflow integration (29% developer adoption vs 18% for Cursor 6). Cursor and Claude Code lead on agentic capability for complex codebases because they scope what the model sees rather than dumping the whole repo into context 6. Your choice depends on which constraint binds tighter: procurement/compliance or context retrieval accuracy at scale.
Footnotes
-
https://tim-schipper.nl/en/blog/claude-code-large-codebase ↩ ↩2
-
https://codealive.ai/en/blog/context-for-claude-code-and-cursor-on-large-codebases ↩ ↩2
-
https://tunedtools.com/blog/claude-code-vs-cursor-large-codebases-3 ↩
-
https://github.blog/changelog/2026-10-28-github-enterprise-now-includes-access-to-github-copilot/ ↩ ↩2
-
https://www.beri.net/article/best-ai-coding-assistants-500-engineer-organizations-2026 ↩ ↩2 ↩3 ↩4
-
https://cloudsail.com/blog/coding-agent-rollout-cost/ ↩ ↩2 ↩3
-
https://www.ai-heroes.co/en-us/blog/claude-code-large-codebases-implementation-guide-2026 ↩ ↩2
-
https://www.infoq.com/news/2026/10/survey-complex-codebases-agents/ ↩ ↩2
-
https://www.infoq.com/news/2026/10/anthropic-source-control/ ↩ ↩2
-
https://daily.dev/posts/ai-coding-agents-are-breaking-big-codebases-dan-adler-sourcegraph-oi3xfnhvv ↩ ↩2 ↩3
-
https://aithority.com/security/gitlab-announces-new-capabilities-to-give-enterprises-speed-and-control-at-agentic-scale/ ↩ ↩2
-
https://venturebeat.com/security/monorepos-make-coding-agents-more-useful-but-compromised-accounts-are-harder-to-contain ↩ ↩2
Recommended Reading
-
Which AI Coding Tool Justifies the Budget for Small Teams?
Copilot Business is the best value for small teams at $19 per seat. Metered AI credits make task volume more important than seat price, and Cursor teams must validate replacement models before OpenAI access ends.
-
AI Coding Agents vs Assistants: 2026 Team Decision Matrix
Review burden, not generation speed, is the AI coding bottleneck. Agents deliver pull requests while assistants suggest lines, and PRs spent 441% longer in review at high AI adoption.
-
AI Coding Agents Ship Code Fast—Can You Trust It?
Qodo leads the public AI code review benchmark at 55.4% F1, but Macroscope removes the most review work by auto-approving low-risk PRs and running validated fixes through CI. Pair a reviewer-assist tool with a security gate like SonarQube or DeepSource when you need merge-blocking enforcement.