---
title: "Why coding agents fail in large codebases (and what to do about it)"
description: "Across 1,281 scored agent runs on 40+ large open-source repos (CodeScaleBench), coding agents fail in five repeatable ways: getting lost in exploration, picking the wrong file or symbol, partial completion, tool thrashing, and context overflow."
url: "https://swe.quest/articles/why-coding-agents-fail-in-large-codebases-and-what-to-do-about-it-67302cc99ae40bda"
canonical: "https://sourcegraph.com/blog/why-coding-agents-fail-large-codebases"
source: "Sourcegraph"
published: "2026-05-08"
difficulty: "medium"
kind: "Research"
reading_minutes: 8
tags: ["ai-coding","ai-agents","search","evals","rag"]
---

# Why coding agents fail in large codebases (and what to do about it)

A post on [Sourcegraph](https://swe.quest/sources/sourcegraph.md), published 2026-05-08, 8 min read, Research. Original: [https://sourcegraph.com/blog/why-coding-agents-fail-large-codebases](https://sourcegraph.com/blog/why-coding-agents-fail-large-codebases)

## Summary

Across 1,281 scored agent runs on 40+ large open-source repos (CodeScaleBench), coding agents fail in five repeatable ways: getting lost in exploration, picking the wrong file or symbol, partial completion, tool thrashing, and context overflow. Indexed code search with keyword, semantic and find-references tools helps most in the 400K–2M LOC range (+0.259 reward delta) but slightly hurts below 400K LOC (−0.080). In one refactoring task it cut tool calls from 96 to 5. Augmented agents were 30% cheaper and 38% faster on average, which supports the claim that these are context-infrastructure problems rather than model-capability problems. The recommended fixes are structural navigation, hybrid retrieval for coverage, and task-aware context management.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)

## Prerequisites

- LLM coding agents ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- code search basics ([easy posts on Search](https://swe.quest/tags/search.md?difficulty=easy))
- tool calling / MCP ([easy posts on AI agents](https://swe.quest/tags/ai-agents.md?difficulty=easy))

## Keywords

CodeScaleBench, Sourcegraph, MCP, Kubernetes, find-references, semantic search

## Related posts

- [How to evaluate Sourcegraph on your own codebase](https://swe.quest/articles/how-to-evaluate-sourcegraph-on-your-own-codebase-d93a19b9258d1431.md): Sourcegraph · 2026-07-31 · Medium · 12 min read · Evaluation, AI for coding, AI agents, Search
  In a 288-task evaluation of the Sourcegraph MCP server, structured code retrieval raised file-level F1 from 0.091 to 0.240 and recall from 0.120 to 0.272, yet aggregate task completion was effectively unchanged.
- [CoderForge-Preview: SOTA open dataset for training efficient coding agents](https://swe.quest/articles/coderforge-preview-sota-open-dataset-for-training-efficient-coding-agents-83e1f3c7a7bdb67a.md): Together AI · 2026-02-25 · Hard · 14 min read · Model training, AI for coding, AI agents, Evaluation, LLMs
  CoderForge-Preview is an open dataset of 258K test-verified coding agent trajectories (155K passing) covering 51K tasks across 1,655 repositories from R2E-Gym, SWE-Smith and SWE-Rebench.
- [Agent-driven development in Copilot Applied Science](https://swe.quest/articles/agent-driven-development-in-copilot-applied-science-57df9b7433878456.md): GitHub Engineering · 2026-03-31 · Medium · 9 min read · AI for coding, AI agents, Developer productivity, Evaluation, Testing
  A Copilot Applied Science researcher built eval-agents, a set of Copilot SDK-based agents that automate analysis of coding-agent trajectories from benchmarks like TerminalBench2 and SWEBench-Pro, and developed it primarily through coding agents.
- [Better tools made Copilot code review worse. Here’s how we actually improved it.](https://swe.quest/articles/better-tools-made-copilot-code-review-worse-here-s-how-we-actually-improved-it-d13b0645c05f1e51.md): GitHub Engineering · 2026-07-10 · Medium · 9 min read · AI agents, Code review, LLMs, Evaluation, Cost optimization
  Swapping Copilot code review's bespoke exploration tools for the shared Copilot CLI tools (grep, glob, view) initially raised review cost and reduced useful comments, because the tool instructions encouraged broad, repo-browsing behavior instead of diff-anchored investigation.
- [Sourcegraph MCP server and a cheaper model beat a Mythos-class model alone](https://swe.quest/articles/sourcegraph-mcp-server-and-a-cheaper-model-beat-a-mythos-class-model-alone-62154a407988cfbb.md): Sourcegraph · 2026-06-16 · Easy · 3 min read · AI agents, Evaluation, AI for coding, LLMs, Cost optimization
  On nine discovery-heavy CodeScaleBench tasks, Claude Sonnet 4.6 using the Sourcegraph MCP server with no source on disk scored a mean reward of 0.698, beating Claude Fable 5 with a full local checkout (0.568) and winning six of nine tasks at $1.02 versus $1.83 per quality point.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
