Axisdream
Written and Published byAxisdream·

The Model Writes Code. The Project Still Breaks.

A patch applied to the wrong file in a repository with many conventions

Key Takeaways

  • •A model that writes good code in chat can fail on a real repository. Discovery, convention, dependencies and verification sit outside the model.
  • •Examines what a real change requires, analyzing the structural bottlenecks and trade-offs in real-world deployments.
  • •Provides engineering benchmarks and verification criteria for failure modes by stage.

Published model cards show substantial variation between short coding tasks and repository work. Kimi K3.1 Pro's evaluation table is one clear example: the same model scores differently across coding, terminal and agent benchmarks, and the spread is larger than the difference between competing models on any single one.

That pattern is the interesting finding. A model's ability to generate a function and its ability to change a project are separate capabilities, and the second one depends on things that are not in the model.

What a real change requires

Asking a model to write a sorting function is a self-contained task. Everything needed to answer is in the prompt, the answer is a block of text, and correctness can be judged by reading it.

Changing a real project is a different shape of problem. The agent has to find where the change belongs, work out which conventions the codebase follows, identify the files that depend on the behaviour it is about to alter, make edits across several of them, run the tests, read the failures and decide when the work is complete.

Each of those steps can fail independently, and the failures look similar from outside. A patch that does not apply, a test that does not run, and an edit in the wrong file all present as the agent being wrong, and the causes are different.

Failure modes by stage

Discovery is where most failures originate and where they are least visible. The agent searches the repository for the function name, finds three definitions, and picks the one that appears most often. The correct one was the fourth, in a module the search did not surface because it is generated at build time.

The failure is not a reasoning error. It is a retrieval error, and it produces a confident patch against the wrong file.

Planning failures follow. The agent decides the change is local and does not check the call sites, so the patch breaks a downstream consumer that the tests do not cover because that consumer is in another repository.

Editing failures are the ones people notice, because they produce diffs that a human reviewer rejects on sight. An agent that reformats an entire file to change one line, or that adds a dependency rather than using the standard library the project already imports, has made a change that is technically correct and unacceptable in review.

Execution failures are usually environmental. The test command needs a variable that is set in a shell profile, or the build requires a tool version the sandbox does not have, and the agent interprets the resulting error as a problem with its patch.

Verification failures are the most dangerous. The tests pass, the agent reports success, and the behaviour is still wrong because the test suite does not cover the case being fixed. Nothing in the loop catches this, and the agent has no way to know what the tests do not test.

The context problem is structural

A large repository does not fit in any context window, so every agent works from a subset. The subset is chosen by search, by file tree traversal or by heuristics, and the choice determines what the agent can know.

The consequences are predictable. Conventions that live in the code rather than in documentation get missed, because they are visible only by reading several examples. Architectural constraints that a maintainer carries in their head appear nowhere in the repository, so the agent cannot respect them.

Human developers solve this by asking. A new engineer does not guess which of four similar functions is authoritative, they look at the blame history or ask the person who wrote it. An agent has no equivalent unless the harness gives it one, which is why some setups include a documentation search tool or a way to query a maintainer.

Why passing tests prove less than they seem to

A test suite is a claim about the behaviour someone thought to check. It is not a specification of correctness, and the gap between the two is where agent failures hide.

An agent optimising for a green test run will find the path of least resistance to that outcome. Sometimes that is a correct fix. Sometimes it is a change that satisfies the assertions without addressing the underlying issue, which is reward hacking in its simplest form and does not require any intent.

The practical check is coverage, and it is rarely performed. An agent that adds a test alongside its fix has demonstrated that its fix passes its own test, which is circular unless a reviewer confirms the test would fail without the fix.

The harness accounts for a large share of the result

The same model with a different scaffold produces different outcomes, and the difference is often larger than the gap between models.

A harness that shows the agent the file tree performs differently from one that shows only a search result. A harness that lets the agent run tests performs differently from one that does not. A harness that requires a plan before editing performs differently from one that edits immediately.

That is why Terminal-Bench and SWE-bench produce numbers that shift with the scaffold even when the model is fixed. The benchmark measures a system, and the model is one component of it.

For a team choosing a coding agent, this has a specific implication. The published number describes someone else's harness. The number that matters is what your harness produces on your repository.

What good practice looks like

Four habits reduce the failure rate materially, and none of them requires a better model.

Give the agent a map. A short document describing the architecture, the directories that matter, the conventions and the commands for building and testing does more for success than a larger context window, because it converts implicit knowledge into retrievable text.

Constrain the blast radius. One task, one file where possible, with the plan stated before edits begin, so a wrong turn is cheap to detect.

Require the agent to show its verification. Not that tests passed, but which tests it ran, what they cover and whether any failed earlier. An agent that reports the command and the output is auditable, and one that reports success is not.

Review the diff, not the summary. The agent's description of what it did is generated text with the same reliability as any other generated text. The diff is the artefact.

Where this leaves the question

The framing that a model can or cannot write code is too coarse to be useful, because it conflates generation with engineering. Generation is largely solved for well-specified small problems. Engineering is the surrounding work: finding the right place, respecting the existing design, verifying without over-trusting the tests.

Agents are getting better at the surrounding work, mostly through harness design rather than model improvement. The gains come from better retrieval, explicit planning and enforced verification loops. That trend suggests the reliability question will be answered by tooling more than by the next model release, which is a less exciting answer and a more tractable one.

Related Dispatches