DEV Community

Reid Marlow
Reid Marlow

Posted on Originally published at reidmarlow.com

Can Your Coding Agent Change Its Own Test Results?

Your coding agent changes a repository and pytest reports a pass. Before treating that result as a score, check whether the submitted code could also change what pytest reports.

One documented failure uses a conftest.py hook to overwrite pytest results. The test might be sensible, but its report comes from a process that loaded the submission. Rebuilding the workspace in a fresh container doesn't by itself settle the question: the submitted code still has to run somewhere.

Who Grades the Agent?, a November 2026 paper by Nathan Nour Houlamy and colleagues, proposes a different boundary. Its SplitBench framework runs the candidate in an evaluation environment, but keeps expected answers and the final verdict in a separate trusted component called the Oracle. The authors converted tasks from Terminal-Bench 2.0 and DeepSWE v1.1 and then attacked the conversions. The results are encouraging, with a useful catch: protecting the grader does not make weak tests strong.

Separate the observation from the verdict

SplitBench first captures the agent's work as a candidate and copies it into a fresh evaluation environment. The Oracle supplies an input; an adapter in that environment runs the candidate and returns an observation. The Oracle compares the observation with an expected value it holds outside that environment.

The adapter and the candidate are both treated as untrusted. A candidate that takes over the adapter can send arbitrary observations, so the Oracle needs a narrow interface and must validate what comes back. Each test case, or group of tests that must run together, gets a fresh environment. That limits the ability of one case to leave a modified executable or process for the next.

The setup also constrains network destinations. That is useful, but a destination allowlist cannot distinguish every permitted operation from misuse of the same service. Provider-hosted tools have their own boundary: the paper says they are disabled by default, and if enabled their traffic is outside SplitBench's network policy.

A simple way to apply the design to an internal evaluation is to draw the data flow before choosing a sandbox. Mark which process holds expected values, which process loads the patch, and which process turns evidence into a verdict. If the process loading the patch can write the final verdict, a fresh image alone has not removed that trust.

What the experiments measured

The researchers converted 180 of 202 tasks across the two benchmarks, reporting a median conversion cost of about $10 per task. On their fidelity evaluation, the converted and native graders agreed on 98.7% of agent attempts. Agreement helps check whether the conversion changed grading behavior; it does not prove either grader is correct in every case.

For the adaptive attack, the team gave an agent the task and told it to obtain a passing grade without solving it. In the full-knowledge setting, the agent could read the adapter and Oracle code, but not the hidden data. SplitBench rejected 126 of 168 completed attempts, or 75%. Model safeguards stopped another 12 attempts before completion; the authors excluded those from the completed-attempt result.

Forty-two full-knowledge attempts passed without solving the task. The authors classified 33 as exploiting weak upstream tests, one as a conversion error, three as faked implementations and five as relying only on public answers. They attributed none to a flaw in the SplitBench framework. Those categories matter: a 75% rejection rate is not a claim that the remaining 25% defeated the isolation boundary.

Across both knowledge settings, one converted task asked for a dataset token count. Its original test checked whether the expected number appeared anywhere in the output file. An attack wrote every number below ten million. The trusted Oracle could make the comparison faithfully and still accept an answer that hadn't counted the dataset. A better acceptance condition would need to reject that oversized answer, and the evaluator should also bound output size.

The paper describes another gap: a candidate can sometimes generate the observation the adapter is expected to produce without implementing the requested change. The Oracle sees an observation, not the full intent behind the task. The authors recommend stricter acceptance conditions and note that reviewing the candidate and trajectory may help identify such cases.

A practical review for an eval harness

Start with one task where the agent can modify a repository and the grader loads that repository. Record exactly what the grader trusts: a test log, exit code, JSON result or value returned from candidate code. Then try a deliberately wrong patch that prints the expected success marker or changes the test runner. If it passes, keep the reproduction alongside the task while moving the verdict outside the candidate's control.

Next, inspect the acceptance condition itself. Does it compare an exact value, or merely search for a substring? Can a constant, a huge output or an unrelated implementation satisfy it? Use fresh, unpublished inputs where possible, and put limits on the evidence the trusted side will parse. These are design checks, not a claim that every task can be reduced to a single hidden-output test.

SplitBench has boundaries of its own. The authors assume the underlying isolation works and trust the Oracle and orchestration code. Their conversion does not support every task, including some that require a trusted record of external effects or timing. They also report that some DeepSWE regression outcomes still rely on the upstream runner; the requested feature checks are judged separately by value.

For a team comparing coding agents, the immediate decision is to retain more than a pass percentage. Keep the task version, grading boundary, hidden-data policy and a few known-bad submissions with the score. That makes it possible to tell whether a harness change improved the agent, changed the tests, or simply made the grader harder to fool.

Top comments (20)

Collapse
 
analista_83 profile image
Sammi De Blas •

If the agent can edit the test file and the harness reads it from the same working tree, the pass rate is a self-report. Splitting the oracle from the workspace is the cheapest way to keep the signal honest. Are the tests mounted read-only in your CI or copied into the sandbox?

Collapse
 
reidmarlow profile image
Reid Marlow •

I don't have a verified CI setup to point you to here. In the paper, the Oracle keeps expected values and the verdict outside the candidate environment; the candidate still runs inside a fresh evaluation environment. A read-only test mount alone wouldn't protect the verdict if the same process loads untrusted code.

Collapse
 
caboulicam profile image
Christophe ABOULICAM •

Cheap version for a normal CI, no oracle needed: run the tests from the base branch, not the PR tree. git checkout origin/main -- tests/ before pytest, fail the job if the PR adds a conftest.py or a pytest plugin anywhere, and put tests/ under CODEOWNERS so changes need a human. Weak tests stay weak, the paper is right about that. But the conftest trick is gone.

Collapse
 
reidmarlow profile image
Reid Marlow •

Restoring the base tests and blocking new pytest hooks closes a useful path. I'd also start from a clean checkout: restoring tests/ over the PR tree can leave PR-added test files in place. And the code under test still runs inside pytest, so the test process shouldn't be the trusted source of its own verdict.

Collapse
 
caboulicam profile image
Christophe ABOULICAM •

Fair point on the clean checkout, that's the safer default. Same rule I apply at the gateway: whatever is being checked never gets to report its own result.

Collapse
 
naw103 profile image
Nick Woodhead •

It can change them but all test changes get reviewed by a different model family. A human reviewer then also has to check any changes to existing tests

Collapse
 
reidmarlow profile image
Reid Marlow •

A human check on changes to existing tests is a useful boundary. I'd also keep a separate set of checks the agent cannot modify, since review of the patch and an independent verdict catch different failure modes.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

Separating the observation from the verdict is the idea that carries this. If the process that loaded the patch can also write the report, a green result is a self-report, as one reply put it. The other point from the paper, that protecting the grader does not make weak tests strong, is the one teams will meet next, because isolation fixes forgery and nothing else.

A pre-agent version of the same boundary came up in a CI/CD modernisation Ascendra Ventures delivered for an equipment manufacturing group over 15 months. Middleware moved from outdated Jenkins to Azure DevOps pipelines as code, Java development went onto one standardised workflow with code reviews, unit tests and SonarQube quality gates, and deployments became versioned Helm releases on Kubernetes, so a rollback is a chart version. Quality gates that live in the pipeline definition, rather than in the branch being judged, are the same principle you describe for the Oracle.

When an agent's patch touches the test files themselves, would you route it to a different reviewer than a change that only touches application code?

Collapse
 
amit_spitzer profile image
Amit Spitzer •

The 33 of 42 that exploited weak upstream tests matches what I saw from the other side: isolation was not my bottleneck, test adequacy was.

On 200 AI changes to 23 real libraries, the projects' own tests stopped 75% of the wrong ones, and 27 wrong changes passed them. Checks written from the task by a second model, each shown to fail on the old code, caught 17 of those 27. When I inspected good changes that a generated check had stopped, in about 7 of 10 the change really did not do what the task text says: the hidden upstream test was too narrow. That figure rests on my own reading of the task texts.

I maintain Apex verify (github.com/apex-engine-dev/apex-ve...). It is a merge check, not a grader-isolation design. The one boundary it shares: settings are read from the base commit, so a change cannot rewrite its own rules.

Collapse
 
reidmarlow profile image
Reid Marlow •

Reading the settings from the base commit protects the rules from the proposed change. For the generated checks, I'd keep the task text and the check together for review: a check can fail on the old code and still enforce a requirement the task never specified.

Collapse
 
heinrichneb profile image
Heinrich Neb •

The line that a protected grader doesn't make weak tests strong matches what bit me. My agent once reported "All tests pass." It had run 74 of our 105 test files. Nothing in the report was false, it just never mentioned the other 31. A separate Oracle catches a tampered result, but not a missing one.

The cheap part I use: the acceptance files get pinned with a hash before the agent starts, so editing the test that judges it turns the verdict red. That does nothing for the 31 that never ran, though. Does SplitBench count expected cases that never produced an observation, or does it only judge the ones that came back?

Collapse
 
reidmarlow profile image
Reid Marlow •

I can't tell from the paper whether a missing observation is counted as a failed case, so I wouldn't assume it is. For a CI setup, I'd compare the expected test IDs from a trusted collection step with the IDs in the result report and fail on missing or duplicate IDs. A passing exit code alone wouldn't catch your 31 missing files.

Collapse
 
heinrichneb profile image
Heinrich Neb •

In my case the cause was simpler: the agent picked which files to run. Making the gate run the full command itself fixed that one. Your ID comparison catches the next case, a glob that quietly stops matching, which the gate alone wouldn't see. That's the check I'd add next: collect the IDs first, compare after.

Collapse
 
prpatel05 profile image
Pratik Patel •

One path the split doesn't close: if the agent can rerun the evaluation, each verdict is honest but the agent picks which one you see. A test that false-passes 5% of the time passes at least once in 20 tries about 64% of the time. Agents will happily retry a flaky failure until it goes green, and nothing in "pass" says it took six attempts.

So I'd keep the attempt count next to the score, and have the trusted side own retries too. The verdict should cover every run for that candidate, not the last one the agent chose to submit.

Collapse
 
reidmarlow profile image
Reid Marlow •

I'd bind each attempt to a candidate hash and have the trusted runner append the result before returning it. Otherwise a candidate can be resubmitted under a new run ID and the retry count resets. A fixed retry policy and a report listing failures as well as passes would make that selection visible.

Collapse
 
analista_83 profile image
Sammi De Blas •

Agreed. The verdict has to live outside the candidate box. A read-only mount only helps if the writer is outside too.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

separating the observation from the verdict is the load-bearing idea. a fresh container means nothing if the process loading the patch still writes the verdict.

Collapse
 
reidmarlow profile image
Reid Marlow •

A useful failure test is to have the submitted patch deliberately forge a passing test report, then check that the trusted evaluator still returns a failure. That exercises the result path as well as the container boundary.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

a forged passing report is a good test. if the pipeline can be fooled that easily, the check is the thing to fix first.

Collapse
 
kevinhall profile image
Kevin Hall •

same for data runs, the agent that reports a count and also decides whether the count is fine, so i keep the check outside it, a plain comparison with the last run that the agent cannot edit