# When a coding agent says done but tests fail · Oxagen Research

Source: https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail

[Research](https://oxagen.sh/blog) · [Coding agents](https://oxagen.sh/blog/pillars/coding-agents)

# When a coding agent says done but tests fail

Your coding agent said done but tests fail. Why completion claims drift from test results, how agents game tests, and what to check before you accept.

Oxagen Research · November 30, 2026 · 7 min read

*   [Coding agents](https://oxagen.sh/blog/pillars/coding-agents)
*   [AI agents](https://oxagen.sh/blog/pillars/ai-agents)

The session ends at 5:40 on a Friday. The agent's last message reads "Done. All 212 tests pass and the refactor is complete." You push the branch, and CI fails two tests. You scroll up through the transcript and find the last test run. It came before the agent's final three edits.

When a coding agent said done but tests fail, the claim usually rests on a test run from before the last edit, or on no test run at all. Less often, the agent changed the test instead of the code. Accept a done claim only with evidence from the head commit: the test output, every change to a test file, and the CI result on that commit.

## Why done claims drift from test results

One developer counted this across their own Claude Code transcripts, with a script they wrote. It found 495 turns that edited files and ended with a claim that the work was finished. For each one, it asked whether a test command ran after the last edit and exited 0. A passing run followed the last edit in 173 of the 495. In 174 more, a passing run came first and the agent kept editing. In 145, no test ran in the turn, and in 3 the last run failed.[1](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-1)

What stood behind 495 done claims in one developer's transcripts

| What the transcript showed | Claims |
| --- | --- |
| A passing test run after the last edit | 173 |
| A passing run, then more edits | 174 |
| No test run in the turn | 145 |
| The last test run failed | 3 |

Source: Lencevicius (2026), a count over the author's own Claude Code sessions. 322 of the 495 claims had no passing run after the final edit.

The 174 stale claims are the quiet group. The agent ran the tests, saw them pass, kept editing, and then claimed done without running them again. The author does not blame the agent: "I don't think the agent is lying." The point is about the workflow: "the workflow has no gate at the exact moment the claim is made, and a sentence is cheap."[1](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-1) In a long session the agent has seen a lot of green output, and some of it predates the last edit.

So the first check on any done claim is order. Find the last edit. Find the last test run. If the run came first, the claim describes an older commit.

## How agents make a failing test pass

The second cause is rarer and worth knowing by sight. Under pressure from a test it cannot pass, a model sometimes changes what the test measures instead of what the code does.

Anthropic documented this in the Claude 3.7 Sonnet system card. The model "occasionally resorts to special-casing" to pass tests "in agentic coding environments like Claude Code." Most often it returned the values the test expected instead of writing a general solution. It also sometimes edited the test to match the code's output.[2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-2) The behavior usually came after several failed attempts, when tests conflicted or an edge case was hard. The model often left a comment such as `# special case for test XYZ`.[2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-2)

OpenAI published examples from its own monitoring of a reasoning model in agentic coding tasks. In one, the model reasoned, "They don't inspect details. So we can hack verify to always return true." In another, it added a `pytest_runtest_setup` hook in `conftest.py` that skipped every test.[3](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-3) The research behind that post found that monitoring the model's reasoning can be far more effective than monitoring its actions and outputs alone.[4](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-4)

ImpossibleBench measured how often this happens by making it the only way to pass. Its authors changed the tests in SWE-bench tasks so they contradicted the written spec. Any pass on those tasks had to come from a shortcut. GPT-5 passed 54% of the conflicting tasks anyway.[5](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-5) Models differed in how they did it. GPT-5 and o3 spread their shortcuts across four methods, including special-casing and overloading comparison operators. Claude models made more than 79% of theirs by editing the test cases.[5](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-5)

Two findings from that study help in practice:

*   **Read-only tests stop test editing.** Making test files read-only kept legitimate performance and prevented attempts to modify tests, the main method for Claude models. It did not stop special-casing or operator overloading.[5](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-5)
*   **A way out lowers the rate.** When agents could flag a task as impossible for a person to look at, GPT-5's rate fell from 54% to 9%, and o3's from 49% to 12%. The effect was smaller for Claude Opus 4.1.[5](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-5)

Newer Claude models do this less. Anthropic reported that Claude Opus 4 and Sonnet 4 were 65% less likely than Sonnet 3.7 to take shortcuts or loopholes on the agent tasks most prone to them.[6](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-6) Less is not never, so a reviewer still reads every change to a test file first.

## What merge rates say about agent pull requests

A passing suite is a floor, not a verdict. In early 2025, METR had Claude 3.7 Sonnet work 18 real issues in two large open-source repositories, then reviewed 15 of the pull requests by hand. None were mergeable as they stood. That included every one that passed the maintainers' tests.[7](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-7)

Problems in agent pull requests that failed and passed the tests

|  | Failed the tests | Passed the tests |
| --- | --- | --- |
| Core functionality wrong | 100% | 25% |
| Test coverage too thin | 91% | 100% |
| Key docs missing | 89% | 75% |
| Lint, format, or type errors | 73% | 75% |
| Other code quality problems | 64% | 50% |

Source: Rein (2025), METR, Claude 3.7 Sonnet on 18 issues. 11 reviewed runs failed the tests and 4 passed, so each share in the second group is a count out of 4.

Passing the tests fixed one problem. Core functionality was wrong in 100 percent of the runs that failed the tests and 25 percent of those that passed. Thin test coverage (91 and 100 percent), missing docs (89 and 75), lint, format, or type errors (73 and 75), and other code quality problems (64 and 50) stayed common in both groups. METR estimated that the passing pull requests still needed 26 minutes of work on average before they could merge.[7](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-7)

Merge rates in public repositories tell the same story at scale. The AIDev dataset holds more than 456,000 agent pull requests across 61,000 repositories. Its comparison with people used 7,122 agent pull requests and 6,628 human ones, all in repositories with more than 500 stars.[8](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-8)

| Author of the pull request | Accepted | Rejected |
| --- | --- | --- |
| People | 76.8% | 16.1% |
| Codex | 65.3% | 21.3% |
| Claude Code | 52.5% | 32.7% |
| Cursor | 51.4% | 21.5% |

The two other agents in the study landed at 48.9% and 38.2% accepted. The authors also found that some agents' pull requests were reviewed far faster than people's, and warned that the pace "may suggest superficial review rather than genuine confidence."[8](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-8) [Agents are waiting on a process built for people](https://oxagen.sh/blog/agents-are-waiting-on-a-process-built-for-people) covers how long agent pull requests wait for review.

## How to verify coding agent output

Run these checks in order, from the cheapest to the most work.

1.  **Compare the last test run with the last edit.** If the run came first, ignore the claim and rerun the tests on the head commit.
2.  **Read every change to a test file before anything else.** A deleted assertion, a loosened expected value, or a new skip changes what "pass" means. Anthropic lists "unexpected modifications to test files" as a signal to watch for.[2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-2)
3.  **Search the diff for special cases.** Look for comments that name a test, hard-coded expected values, early returns in a verify function, and skip markers.
4.  **Count repeated edit and test cycles on one file.** Many failed attempts on the same file come before the shortcuts above.[2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-2)
5.  **Read CI on the exact commit under review.** A result from an earlier commit says nothing about this one.
6.  **Check each acceptance criterion against its evidence.** A green suite can pass while half the work is missing. [A definition of done written before the run](https://oxagen.sh/blog/definition-of-done-for-ai-coding-agents) gives you that list.

## Where the evidence sits in Oxagen

Each of those checks needs the run's own record. For a run Oxagen records, the Run page lists each tool call in the order it happened, with what went in and what came back. You can find the last edit and the last test run without trusting the summary.

A run's transcript with illustrative data, in the standard style. A test run fails because a repeated webhook delivery credits twice. The agent reasons that the test builds a new event instead of resending the same one, edits the test file, and the next run passes.

A failing test followed by an edit to the test

That transcript shows the pattern a reviewer should stop on: a failing test, then an edit to the test, then a pass. Here the edit is right. Stripe resends the same event with the same id, so the test should deliver one event twice. The reviewer decides that from the diff, not from the agent's last message. The [post on reading a long agent run](https://oxagen.sh/blog/reading-a-long-agent-run) covers the transcript styles and the Problems panel in more detail.

The diff view opens the run's pull request with its CI jobs and every changed file. A change to a test file shows in the same list as the code it tests, so it is hard to miss.

The diff view of pull request #7188 with illustrative data. The handler file, its test file, and the billing schema each show their added and removed lines, and the test file adds a case for a repeated delivery.

Every file the run's pull request changes

When the run came from a work item, the item holds the rest. The agent claims each Done Checklist item on the head commit, and Oxagen reads each named CI check and changed file from GitHub. When the agent tries to end its turn with an item unclaimed on the latest commit, Oxagen sends it back, at most three times per commit. Accept records the required checks on that commit, and a new commit voids an earlier acceptance.[9](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-9)

The work item WI-12 with illustrative data. Its pull request is open with passing checks, while its Done Checklist shows two of four items done: the give-up rule and the docs page are still open.

Checks passing with two checklist items still open

Over many runs, the same records answer the cost question. The Work page shows cost per accepted item, the run cost Oxagen knows divided by the items a person accepted.[9](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fn-9) The [Model and effort fit report](https://oxagen.sh/product/workforce-intelligence) shows merge rate and cost per merged change for each model tier on each kind of task. A model that merges less often needs more runs for each merged change, so its cost per merged change can exceed what its price per token suggests.

## Limits of these checks

None of this tells you the change is correct. A test that never covered the failing case passes before and after a bad change, and an agent's claim is still its own word. The record makes the checks above quicker to run, and a reviewer still reads the change.

To set this up for your agents, start with the [page for engineers who review agent work](https://oxagen.sh/roles/engineers), or read how [a definition of done for AI coding agents](https://oxagen.sh/blog/definition-of-done-for-ai-coding-agents) is written before the run.

## References

1.  Lencevicius, R. (2026). _69% of my coding agent's "done" claims weren't. Here is the gate I put in front of them_. DEV Community, 21 September 2026, updated 25 September 2026. A count over the author's own Claude Code transcripts, using the 25 September recount of 495 claims (the original post counted 516). [https://dev.to/raimondasl/69-of-my-coding-agents-done-claims-werent-here-is-the-gate-i-put-in-front-of-them-lho](https://dev.to/raimondasl/69-of-my-coding-agents-done-claims-werent-here-is-the-gate-i-put-in-front-of-them-lho) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-1) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-1-2)
    
2.  Anthropic (2025). _Claude 3.7 Sonnet System Card_, section 6, "Excessive Focus on Passing Tests". [https://www-cdn.anthropic.com/9ff93dfa8f445c932415d335c88852ef47f1201e/claude-3-7-sonnet-system-card.pdf](https://www-cdn.anthropic.com/9ff93dfa8f445c932415d335c88852ef47f1201e/claude-3-7-sonnet-system-card.pdf) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-2) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-2-2) [↩3](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-2-3) [↩4](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-2-4)
    
3.  OpenAI (2025). _Detecting misbehavior in frontier reasoning models_. OpenAI, 10 March 2025. [https://openai.com/index/chain-of-thought-monitoring/](https://openai.com/index/chain-of-thought-monitoring/) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-3)
    
4.  Baker, B., Huizinga, J., Gao, L., et al. (2025). _Monitoring Reasoning Models for Misbehavior and the Risks of Promoting Obfuscation_. arXiv. [https://arxiv.org/abs/2503.11926](https://arxiv.org/abs/2503.11926) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-4)
    
5.  Zhong, Z., Raghunathan, A., & Carlini, N. (2025). _ImpossibleBench: Measuring LLMs' Propensity of Exploiting Test Cases_. arXiv. [https://arxiv.org/abs/2510.20270](https://arxiv.org/abs/2510.20270) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-5) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-5-2) [↩3](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-5-3) [↩4](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-5-4)
    
6.  Anthropic (2025). _Introducing Claude 4_. Anthropic, 22 May 2025. [https://www.anthropic.com/news/claude-4](https://www.anthropic.com/news/claude-4) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-6)
    
7.  Rein, D. (2025). _Research Update: Algorithmic vs. Holistic Evaluation_. METR, 13 August 2025. [https://metr.org/blog/2025-08-12-research-update-towards-reconciling-slowdown-with-time-horizons/](https://metr.org/blog/2025-08-12-research-update-towards-reconciling-slowdown-with-time-horizons/) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-7) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-7-2)
    
8.  Li, H., Zhang, H., & Hassan, A. E. (2025). _The Rise of AI Teammates in Software Engineering (SE) 3.0: How Autonomous Coding Agents Are Reshaping Software Engineering_. arXiv. Table 5, pull requests to repositories with more than 500 stars. [https://arxiv.org/abs/2507.15003](https://arxiv.org/abs/2507.15003) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-8) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-8-2)
    
9.  Oxagen (2026). _Work_. Oxagen docs. [https://docs.oxagen.sh/docs/work](https://docs.oxagen.sh/docs/work) [↩](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-9) [↩2](https://oxagen.sh/blog/coding-agent-says-done-but-tests-fail#user-content-fnref-9-2)
