Skip to content
155.5k

BlogGuides

Why coding agents fail on large codebases

Why coding agents fail on large codebases

Coding agents fail on large codebases for a simple reason: the repository no longer fits in the window, and the agent has to find the right files by walking and searching. When that search goes wrong, the agent gets lost, edits the wrong symbol, finishes only part of the work, burns the window on tool calls, or overflows context and starts dropping what it already knew.

Those five patterns are not a slogan we invented. They come from Why coding agents fail on large codebases, a Sourcegraph post by Stephanie Jarmak dated 8 May 2026, based on 1,281 agent runs across more than 40 repositories. This page explains those patterns, points at where a queryable map of the code helps, and is honest about what it does not fix. We make Graphify. We did not repeat Sourcegraph's runs, and this is not a new benchmark.

If you want a practical setup for one agent, start with how to give Codex context on a large codebase. If the repository is a monorepo, see monorepo context for AI agents. For the layers you can add around the agent, see best context engineering tools going into 2027.

What the Sourcegraph study found

Stephanie Jarmak's 8 May 2026 post reports 1,281 agent runs on more than 40 repositories, and names five failure patterns. The line-count threshold around 400,000 lines is their finding, not ours. We did not repeat the runs for this page.

The five patterns, in the language of that post, were:

  • Lost in the codebase. The agent spends the session hunting for the right files and never settles on a plan.
  • Wrong file or symbol. It finds a name that looks right, then edits a helper, a test double or a same-named function in another package.
  • Partial completion. It changes the obvious site and misses other call sites, related tests or a second package that needed the same update.
  • Tool thrashing. It flips between search, read and edit tools without making progress, and the window fills with traces.
  • Context overflow. Retrieved files, tool output and conversation history crowd out the instructions and the facts the agent already had.

Sourcegraph's write-up is also careful about what "large" means. In their results, failures became much more common around 400,000 lines of code. That is their threshold, on their tasks and their agents. Your repository may fail earlier if the structure is dense, or later if the work stays inside one package.

Why the patterns show up

A coding agent does not start a task with a map of the repository. It starts with a prompt, a set of tools and a working tree. On a small project, reading a few files is enough. On a large one, that walk is the work, and it is also the failure mode.

Wrong file or symbol is a name collision problem. Many codebases have more than one parse, Handler or Client. Search by string will return all of them. A language server can disambiguate inside a loaded project. A code graph can return callers of a specific node, with a file and a line, if the parser bound the name.

Partial completion is an impact problem. The agent sees the function you named and not the other packages that import it. How to give Codex context on a large codebase walks through asking for callers before the edit, for that reason.

Tool thrashing and context overflow are retrieval problems. If the agent has three search tools and no rule for which one to use, it will try all three. Best context engineering tools going into 2027 argues for one instruction file, one map or search tool, and a clear rule for when to look things up.

What a queryable map changes

Graphify keeps a persistent graph of the repositories you index. Agents query it over MCP for symbols, callers and impact. The Graphify CLI can build the same kind of graph locally with uv tool install graphifyy, then graphify update . and graphify affected. On public checkouts we have already published, those commands returned importers with file and line. Results vary by codebase.

That does not stop coding agents from failing on large codebases. A queryable map of callers and impact can shorten the search for the right symbols, which is where several of those failures start. It will not catch a bad edit, it will not enforce a rule the agent never loaded, and it will not invent callers that the parser cannot see.

Tell the agent when to use the map. A short block in AGENTS.md that says "before you edit a public function, ask who calls it" is more useful than connecting another MCP server and hoping the model picks it.

When Sourcegraph may fit better

Sourcegraph may fit better when the agent needs to search text, diffs and commit history across every repository you can access, or to follow a symbol with precise SCIP navigation. Their study also used search infrastructure as part of the setup. Graphify combines and queries the repositories you index.

Cross-repository code search, dated 29 November 2026, is the comparison of that search job.

What this page is not

This page explains the failure patterns. A later data post may measure how often agents miss callers on real pull requests. That experiment is not this article.

We also have not claimed that Graphify would have scored better on Sourcegraph's 1,281 runs. We did not run that comparison.

Try it

Connect a repository at app.graphify.com, add the hosted MCP to your agent, and ask who calls a function you plan to change, before you change it.

Prefer to stay local? Run uv tool install graphifyy. Related reading: how to give Codex context on a large codebase, best context engineering tools going into 2027, and what is a code graph.

FAQ

Why do coding agents fail on large codebases?

They fail when the repository no longer fits in context and the agent has to discover the right files by walking and searching. Sourcegraph's 8 May 2026 study of 1,281 runs across more than 40 repositories grouped the failures into five patterns: lost in the codebase, wrong file or symbol, partial completion, tool thrashing and context overflow. Failures rose around 400,000 lines of code in that study.

What did the Sourcegraph study actually measure?

Stephanie Jarmak's 8 May 2026 post reports 1,281 agent runs on more than 40 repositories, and names five failure patterns. The line-count threshold around 400,000 lines is their finding, not ours. We did not repeat the runs for this page.

Does a code graph stop coding agents from failing on large codebases?

No. A queryable map of callers and impact can shorten the search for the right symbols, which is where several of those failures start. It will not catch a bad edit, it will not enforce a rule the agent never loaded, and it will not invent callers that the parser cannot see.

When might Sourcegraph fit better for large codebases?

Sourcegraph may fit better when the agent needs to search text, diffs and commit history across every repository you can access, or to follow a symbol with precise SCIP navigation. Their study also used search infrastructure as part of the setup. Graphify combines and queries the repositories you index.

Is this the same as a benchmark of agents on large pull requests?

No. This page explains the failure patterns. A later data post may measure how often agents miss callers on real pull requests. That experiment is not this article.

Use Graphify in your agent

Add Graphify to ChatGPT, Claude, Cursor, Grok Bot and more in one click.

Try Graphify now.

Try for free