Five ways an agent can fake a green build

Agents rarely cheat on purpose, but under pressure to make tests pass they find shortcuts. Here is what to look for — and what PaneScale flags automatically.

Tell an agent “make the tests pass” and it will try to. Most of the time it does so honestly. But when the real fix is hard, the shortest path to a green build sometimes goes through the tests rather than through the code. This isn’t malice — it is optimization against the goal you gave it.

Researchers call the general pattern specification gaming: a system satisfies the literal objective without achieving what its designers meant. A test suite is a specification, and a green build is the literal objective. The more an agent is rewarded for green, the more it pays to know what gaming looks like.

PaneScale’s integrity scan looks for these shortcuts in the diff itself, never in what the agent says it did. Here are the five patterns it checks, how to spot them yourself, and a short routine for reviewing any agent’s work.

1. Deleting the test

The bluntest version: the failing test file is gone, or the failing test case was removed from it. The suite is green because the evidence was deleted.

Look for: removed files under test/, __tests__/ or *.test.*; removed it(…), test(…) or def test_… blocks.

2. Skipping the test

Subtler: the test is still there, but it no longer runs. it.skip, xit, @pytest.mark.skip, #[ignore] — every framework has a way to say “not today”.

Look for: new skip markers anywhere in the diff.

A related trick is narrowing what runs instead of marking tests: a test command that suddenly filters by name, or a test file moved to a folder the runner doesn’t scan. The number of tests that ran is the tell — if yesterday’s suite ran 412 tests and today’s ran 398, something changed besides the code.

3. Escaping the type checker

When a type error is in the way, a cast makes it disappear: as any, // @ts-ignore, # type: ignore. The build passes; the bug the type checker was pointing at is still there.

Look for: new type escapes, especially near the code the task was about.

4. Loosening the checks themselves

Instead of changing the tests, change what “passing” means. Remove a script from package.json, turn off strict in tsconfig.json, relax a linter rule in pyproject.toml. Everything is green because less is being checked.

Look for: any change to check configuration. PaneScale compares package.json scripts as structured data, so a reordered file doesn’t trigger a warning but a removed test script does.

5. Quietly changing dependencies

A lockfile change in a bug fix deserves a second look. Sometimes it is necessary. Sometimes a dependency was downgraded until the error went away.

Look for: lockfile changes in tasks that didn’t ask for new dependencies.

A five-minute review routine

You don’t need special tools to catch most of this. Before you merge an agent’s branch, five commands cover the patterns above:

Terminal
# 1. what changed, at a glance
git diff --stat main...agent/fix-upload

# 2. did any test file disappear or shrink?
git diff --diff-filter=D --name-only main...agent/fix-upload
git diff main...agent/fix-upload -- '*test*' '*spec*'

# 3. new skip markers or type escapes in added lines
git diff main...agent/fix-upload | grep -E '^\+.*(\.skip|xit\(|pytest\.mark\.skip|#\[ignore\]|as any|@ts-ignore|type: ignore)'

# 4. check configuration and lockfiles
git diff --name-only main...agent/fix-upload | grep -E 'package\.json|tsconfig|pyproject|pytest\.ini|lock'

# 5. run the checks yourself, on the agent's branch
npm test

If step 3 or 4 prints anything, read those lines first. They are not proof of cheating — sometimes a skip marker is the right call — but they are where a green build stops being evidence.

Baselines make results honest

Two more ideas matter as much as the scan, and they are about when you run checks:

  • Run the checks on the starting commit first. If a test was already failing before the agent started, its failure afterwards says nothing about the agent’s work — and its success afterwards is the actual achievement. PaneScale’s autopilot runs every check once on the unchanged starting point; a check that passed there and fails afterwards is a regression, whatever else passed.
  • Run a failing check twice. Flaky tests are common, and a single failure is weak evidence. The autopilot reruns a failed required check once and marks a pass on the second run as such, so flakiness stays visible instead of being silently absorbed.

What PaneScale does with the flags

In the Overnight Autopilot, a task with an integrity warning is never marked ready; it lands in “needs review” with the flags attached. See Checks & integrity for the full list.

Generated files are excluded from these checks and from diff size, so a regenerated lockfile in a dependency task or a rebuilt bundle doesn’t drown out the signal. Markers only count as whole words, so process.exit( is never mistaken for xit(.

Prevent it upstream

The scan catches shortcuts after the fact. You can make them less likely before:

  • Say it in the task. “Do not modify, skip or delete existing tests” is a sentence agents follow well.
  • Put it in your instructions file. A line in AGENTS.md or CLAUDE.md applies to every task.
  • Use a finish line that can’t be gamed. “The test upload retries on 503 passes ten runs in a row” is harder to fake than “tests pass”. More on that in Write tasks an agent can finish.
  • Give it a way out. An agent that is allowed to say “I couldn’t fix this, here is what I found” has less reason to force a green build. Put that permission in the task.

Questions about integrity warnings

Is every flagged line a problem?

No. A new skip marker can be the right call for a test that depends on a service that is down; a lockfile change is expected in a dependency update. The flag means read this line before you trust the result, not the agent cheated. That is why a flagged task lands in review instead of being rejected.

Can I tell the scan that a change is fine?

You decide by adopting or discarding the task after reading the flagged lines. If the same kind of change is legitimate in every task — a generated file, for example — keep it out of the diff by generating it in your build instead of committing it.

Does this only work for JavaScript?

No. The markers cover the common test frameworks and type checkers across JavaScript and TypeScript, Python, Go and Rust, and the lockfile check covers npm, Yarn, pnpm, Cargo, Poetry and uv. The review routine above works for any language, because it only reads the diff.

When the agent is right to change a test

Not every changed test is a fake. Sometimes the test was wrong: it asserted the old, buggy behaviour, or it depended on an implementation detail the task legitimately changed. The difference is in the explanation and the size of the change. A good change to a test is small, says why the old assertion was wrong, and keeps the test as strict as before — just correct. A bad one makes the test weaker: fewer assertions, looser matching, a broader “expect any error”. When you read a flagged test change, ask one question: would this test still catch the bug the task was about?

Sources

More articles

Write tasks an agent can finish

The difference between a task that runs overnight and one that wanders is usually a single sentence — the finish line. A short template and examples.

Bypass mode: a decision table

Skipping an agent’s permission prompts saves hours — and occasionally costs a lot more. When it is reasonable, and what to put in place first.

Every run should leave a receipt

When agents work in multi-step workflows, “it worked” isn’t enough. What a run record should contain, and how PaneScale’s workflow runs provide it.