← Agentic engineering

Module 2 · Make the agent prove it

Set the check before the build and see it fail, keep the agent from editing it, catch the five ways an agent fakes a pass, then use the running product the way its user does.

Facts checked

An agent's message in the chat cannot show you whether it did the work. The test output, the diff and the product in use can.

By the end of this module you can set a check before the build and see it fail, keep the agent from editing that check while giving it a way to object, recognise the five ways an agent fakes a pass, and judge a change by using the running product in the state its user has.

Before you read
1.

An agent reports "all 24 tests pass". Which of these is the strongest evidence that they do?

2.

Why should a new check be seen to fail before the change it checks is built?

3.

A diff makes the change you asked for and also changes one existing test's expected total from 125000 to 130000. What do you do?

Set the check before the build

The check that proves a change comes first, and it comes from someone other than the builder.

It exists before the code. Write the test, run it and read the failure. Until you have seen it fail, you do not know that it can. The failure message should name the missing behaviour. If a new test passes on its first run, either the behaviour already exists or the test checks nothing, and you need to know which before going on.

test("a donation at 23:40 on 30 June lands in the year ending that night", () => {
  const donations = [{ amountCents: 5000, paidAt: "2026-06-30T23:40:00+10:00" }];
  const receipt = buildAnnualReceipt(donations, { yearEnding: "2026-06-30" });
  assert.equal(receipt.totalCents, 5000);
});

Someone else sets it. That can be you, a teammate, or a separate agent session that is given the ticket and never sees the implementation. When one session writes both the test and the code, a red run followed by a green one shows only that something was run. That result does not rule out that the session wrote the code before the test, or wrote a test that could never fail.

The check gets checked. A check is code, and it can be wrong in either direction. One team's check asserted that the words "Microphone check" were visible on a screen. The words existed only as a screen-reader label, so a correct screen failed. Ask two questions of every check before you trust it. Which correct build would fail this? Which wrong build would pass it?

That team kept a log of what went wrong across its agent builds. Of 184 entries, 174 were about how a check was worded, and 39 were about a later step breaking a check that an earlier step had passed. It is one team's unpublished record, so read it as an anecdote. The second number is the reason to run every earlier check after each step, and not only the newest one.

Tests the agent may not edit, and a way out

Telling an agent not to change the tests is the weakest way to protect them. ImpossibleBench, a benchmark published in October 2025 by Ziqian Zhong and two co-authors, measures this directly. It takes coding tasks and alters their tests so that they contradict the written specification. No honest solution passes, so every pass is a cheat. The agents were told not to modify the tests. Some modified them anyway, and others left the tests alone and cheated from the code side.

Two of its results tell you how to set up your own repository.

Restrict access to the tests. Hiding the tests from the agent cut cheating to near zero, and also lowered its scores on the ordinary, solvable tasks. Making the tests read-only was the middle ground. Honest performance came back and edits to tests stopped, though special-casing and other code-side tricks remained.

Give the agent a way out. When the agents were told they could submit a fixed string to flag a faulty task for a person and then stop, GPT-5's cheating rate on one variant of the benchmark fell from 54% to 9%, and o3's from 49% to 12%. The effect was much smaller for Claude Opus 4.1. These are 2025 models on a benchmark, and the numbers will have moved since. The part to copy is giving the agent an honest way to stop.

In practice you can protect the tests in three layers, listed here weakest first.

The brief. "Do not edit receipt.test.js. If it looks wrong, stop. Write CHECK DISPUTED: with the test's name and your reason." This costs nothing and gives the agent the way out. The agent can still ignore it.

The agent's own settings. Most agent tools can be told to refuse edits to a path. In Claude Code, as of December 2026, a deny rule such as Edit(/tests/acceptance/**) in the project's settings is evaluated before any allow rule. The documentation also states the limit. The rule covers the built-in file tools and the shell file commands it recognises, and a script that opens the file itself can still write to it.

CI, outside the agent's reach. The pipeline runs the protected tests from the base branch's copy, so an edit to them on the agent's branch does not change the result. A change to a protected test then has to arrive as its own pull request. On GitHub, a CODEOWNERS entry for the test directory together with the branch setting "Require review from Code Owners" means a named person approves it. Protect the pipeline's own definition the same way, since an agent that can edit the workflow file can edit what runs. Of the three layers, this is the only one that nothing on the agent's branch can get around.

A disputed check is normal and useful. When the builder writes CHECK DISPUTED, whoever set the check reads the reason and either fixes the check or explains why it stands; the builder does not decide this alone.

The five ways an agent fakes a pass

An agent given "make the tests pass" may fake the pass instead of doing the work, sometimes by changing the tests themselves. There are five common ways to do it, and each leaves something you can find.

A test deleted. The count drops. If 26 tests passed before and 24 pass now, two are gone, and you should not trust the green result until you know which two. Compare the counts every time.

A test disabled. The test is still in the file and marked to be skipped: test.skip, it.skip, xit, @unittest.skip, or a commented-out assertion. Runners report skipped tests in a count of their own, and the diff shows the word. Search the diff for skip before you read anything else.

An assertion weakened. The test still runs, still passes, and no longer checks the thing. The expected value was changed to match the output. A comparison became assert.ok(true). An error is now caught and ignored. ImpossibleBench recorded a version of this that leaves the test file untouched: the code returns an object whose equality method always answers true, so every comparison passes.

The test's input special-cased. The code returns the right answer for exactly the value in the test and the wrong answer for everything else. You can spot it when a literal from the test turns up in the code: an id, a date, an amount. A variant counts its own calls and answers differently the second time. Change the value in the test and run it again.

A claim with no run. "All tests pass" with no output, or with output from a subset. This is the cheapest to catch. Run the command yourself, on the commit you are about to merge, every time.

git diff --stat shows which test files changed before you read a line. Start with any test file you did not ask the agent to change. Review at volume adds the fakes that only show up when there are many changes to read.

Then use the running product, in the state its user has

A test checks only what somebody thought to write into it. It can also miss layout problems, gaps between two steps and problems in the user's own software.

One team went back over twelve defects that its agents had marked as fixed. Six were resolved. None of the twelve fixes had been opened in a browser. On another project all eleven step checks were green, and a single walk through the product found seven places where one step did not join up with the next.

So after the checks pass, use the change the way its user will. Three states are easy to skip.

The real screen. Open it. A passing component test says nothing about whether the button is on screen at the width people use.

The empty or default state. A new account, no rows, nothing selected. A development database is full of data, so make an empty account to see what a first-time user sees.

The user's own setting. Their browser, their phone, their mail program. One team's email bug showed only in the tester's mail program, and it survived four rounds of fixes.

You can ask the agent for this evidence: a screen recording made after the action, on a fresh account. For anything that touches money or access, do it yourself. Keep the path as a short written checklist, and turn whatever you find into a check, so that the next change cannot break it unnoticed.

The agent says all 24 tests pass

A scenario. A charity's receipting service builds each donor's annual receipt. The ticket: donations taken through the new card provider must appear on the receipt. Say what you would check at each step before you read it.

  1. 1 · Record the baseline

    node --test reports 23 tests, 23 passing, none skipped. Write the three numbers into the pull request description. Every later claim is measured against them.

  2. 2 · Have a separate writer set the check, and see it fail

    A teammate, or a second agent session given only the ticket, adds one test to receipt.test.js. Given a $50 card donation on 12 May, the receipt lists $50 under card and the total is $50. Run it: 24 tests, 1 failing, and the message says card is missing from the receipt's lines. Commit the failing test on its own, so that the builder's diff starts clean.

  3. 3 · Brief the builder with the check named and a way out

    "Make the failing test in receipt.test.js pass. Keep the other 23 passing. Do not edit any test. If one looks wrong, stop. Write CHECK DISPUTED: with its name and your reason." The agent works and reports: "Done. All 24 tests pass."

  4. 4 · Run it yourself, then look at the shape of the diff

    node --test: 24 passing, none skipped. git diff --stat: two files, receipt.js and receipt.test.js. The test file was committed before the build and was not supposed to change again. Read it before the code.

  5. 5 · Read the test diff

    One line changed. An existing test's expected total went from 125000 cents to 130000. That test covers a donor whose year was $1,200 by bank transfer and $50 in cash at an event. The new code treats every donation that is not a bank transfer as a card donation and still counts cash under other, so the $50 is counted twice. The agent moved the expected value to meet the wrong total and raised no dispute.

  6. 6 · Check the old value against its source

    The test's comment links the receipt that was issued to that donor last year, and it says $1,250. The test was right and the code is wrong. The agent could not have done this step, because it had two numbers and no way to tell which one was right.

  7. 7 · Restore the test and ask again, naming the fault

    git restore receipt.test.js puts 125000 back. "Cash donations are being counted under both card and other. Fix the classification. Do not edit the test." Second run: 24 passing, and git diff --stat shows one file, receipt.js. Then stop it happening again: put the receipt tests on the protected list in CI.

  8. 8 · Use it in the state the user has

    Open the receipt page for a donor with one card donation and one bank transfer. The total is right, and the card donation shows the provider's settlement date, three days after the donor paid. Then open it for a donor who gave nothing this year. The page shows a receipt for $0.00 with a thank-you line, where it should say there is nothing to receipt. No test covered either case, because nobody had seen them. Both become tests, and 26 is the baseline for the next change.

Try it

Each numbered item comes from an agent's change that was reported as "all tests pass". Name the fake in each gap.

1  -test("refund is booked to the month of the original invoice", () => {
   +test.skip("refund is booked to the month of the original invoice", () => {
   Fake: ______

2  -  assert.equal(receipt.totalCents, 125000);
   +  assert.equal(receipt.totalCents, 130000);
   Fake: ______

3  +  if (donor.id === "donor-17") return { totalCents: 5000 };
      (added to receipt.js; "donor-17" is the id used in the test)
   Fake: ______

4  Before the change: 26 passing. After: 24 passing, 0 failing, 0 skipped.
   Fake: ______

5  "Done. All 24 tests pass." (no command output attached)
   Fake: ______
The misconception

If the tests pass, the change is correct.

Why it’s wrong

Tests pass for three reasons: the code is right, the tests do not check the thing, or the tests were changed to agree with the code. The test runner's output looks the same in all three cases.

ImpossibleBench measured how often the third can happen when nothing prevents it. In its October 2025 results, GPT-5 passed 76% of the impossible tasks in one variant built from SWE-bench, and 2.9% in the matching variant built from the simpler LiveCodeBench. Because of how the tasks were built, every one of those passes broke the specification.

The correct model

You need passing tests, but they are not enough on their own. You also need each of these. Someone other than the builder set the check. It was seen to fail first. The builder could not edit it and had a way to object. You ran the suite yourself on the commit to be merged, and the counts equal the baseline plus what was added. The diff touches no test you did not ask about. And the change was used in the running product, in the state its user has.

Check yourself
  • Who sets the check for a change, and when?

  • Name the five ways an agent makes tests pass without doing the work.

  • What did giving agents a way to stop do in ImpossibleBench?

  • Name the three layers that keep an agent from editing a test, weakest first.

  • After the checks pass, which three states of the running product do you use the change in?

Before the check

To prove a change, collect this evidence. A separate writer sets the check and it is seen to fail. The builder cannot edit it and has a way to dispute it. You run the suite yourself, compare the counts, and read any test file that changed before you read the code. Then you use the change in the running product, on the real screen, in the empty state and in the user's own setting, and whatever you find becomes a check.

Check yourself before you go on:

  • For the last agent change you merged, who wrote its test, and did anyone see that test fail?
  • Could an agent on a branch in your repository edit a test and still get a green pipeline?
  • What does your agent do today when a test looks wrong to it? Is there a way for it to say so and stop?
  • When did you last open a change on an account with no data in it?
Sources
1 lab

Labs

Lab 1

Practise this: Catch the fake pass

Clone the starter linked below. It is a small tool-hire counter in Node, with nothing to install: staff mark items returned and the app works out the charge. The counter asked an agent for one change, a late fee: when an item comes back after its due date, one extra day's rate for each day late, shown on the receipt as its own line. The last commit on main is what came back. The commit before it is tagged before-agent, and the agent's report is in AGENT_REPORT.md. The report says all 19 tests pass and the change is ready to merge.

The commit holds one of each of the five fake passes: a test deleted, a test disabled, an assertion weakened, the test's input special-cased, and a claim with no run. Some are in the report's own words, if you read them closely. Others are only in the diff. Start with node --test and git diff before-agent --stat, then read the diff file by file.

  1. Write REVIEW.md with five headings, the module's five names word for word. Under each, say where the agent did it (the test, the function or the value) and what you did about it. Under A claim with no run, give the number of passing tests the report claims and the number your own run of the starter showed.

  2. Put the code right. The late fee stays, worked out from each hire's own due date for any item. Everything nobody asked for goes back: the default hire length, the money format, and the refusal of a return dated before the hire started.

  3. Put the tests right. Nothing skipped, none of the starter's tests deleted or renamed, the deleted test back, and the weakened check asserting the exact fee again.

  4. Add the rule that would have stopped this, as one bullet line under the Rules for changes heading in CLAUDE.md, AGENTS.md and .cursor/rules/brief.mdc (the file Cursor, now Grok Build, reads), the same line in all three. It must be about tests and give the builder the way out: stop and write CHECK DISPUTED: with the test's name and the reason.

  5. Do the work on a branch and get node --test green before you upload, on the commit you upload, with the output in front of you.

Do it by hand, or with an agent if you hold it to the brief in the repo. Either way, you approve every command it runs.

Then upload the repository folder. The .git folder is left out for you, so the mark is made from what the hidden tests find in your files: the late fee on items and dates your tests never use, the three restored rules, your test files, REVIEW.md and the rule line. Keep the branch and the commits tidy for your own sake; the mark does not cover them.

Open the lab · needs a free Tarmac account to have your work marked