All courses

Verify an agent change instead of trusting it

For a given change, build a short verification plan: reproduce the problem, see the tests fail and then pass, judge whether the tests could catch a real bug, pin behaviour before refactors and run the toolchain checks. Explain what evidence each step gives you.

Builds on: Mocks that test nothing, Tests that restate the implementation, See it fail: red before green and break-it checks, Pin behavior before a refactor, Let the toolchain check first

Read it card by card Start the whole course

The agent says it's fixed. Is it?

You asked the agent to fix a bug: applying the same coupon twice discounts the order twice. A minute later it reports: "Fixed in `apply_coupon`, added a regression test, all 212 tests pass." The diff is a 3-line guard and one new test. Before you approve, what do you actually know? Only what the agent says, including that tests are green. You have not seen anything run yet.

Green is a claim, not evidence

The agent works toward the signal it can see: tests green, error gone. Its summary reports that signal, not the goal. Each part can be true while the bug survives. The new test may never hit the bug, may pass without the fix, or may restate the code. The edit may also have shifted other behaviour. **Later cost:** you approve, the double discount ships, and a green test now vouches for it.

A verification plan, step by step

Each step gives you one piece of evidence: 1. **Reproduce** the bug on the old code. Evidence: it is real, and you know its symptom. 2. **Red, then green**: the new test fails without the fix and passes with it. Evidence: the test targets this bug. 3. **Could it catch a bug?** Expected values come from the spec, the real code runs (not a mock), and a break-it check turns it red. Evidence: the test has teeth. 4. **Pin behaviour** if the diff reshaped existing code: record the old code's outputs in tests, then run them on the new code. Evidence: nothing else changed. 5. **Toolchain**: full suite, types, linters, CI, config untouched. Evidence: nothing broke elsewhere.

Running the plan on the coupon fix

You keep the agent's test, remove just the 3-line guard and rerun: green. That is the tell. The test never reached the bug, so it proves nothing about the fix. You ask for a test that applies the coupon twice. Old code: red, total 81. With the fix: green, 90. Flip the guard's condition: red again. Last, run the full suite, mypy and CI, and check that the diff added no `# type: ignore` comments or config changes.

The test that could not fail vs. one that can

BAD is the agent's test. BETTER is the one you asked for. Both expect 90. That value comes from the spec ("10% off, once"), not from the code's own formula. The difference is the second call. Only BETTER repeats the action that triggered the bug, so only BETTER turns red when the guard is missing.
// Python
# BAD
def test_coupon():
    o = Order(total=100)
    apply_coupon(o, "TEN")
    assert o.total == 90

# BETTER
def test_coupon_applies_once():
    o = Order(total=100)
    apply_coupon(o, "TEN")
    apply_coupon(o, "TEN")
    assert o.total == 90

Earn the evidence yourself

A summary and a green suite are claims. Turn them into evidence: - Reproduce the bug. - See the test go red, then green. - Break the fix to prove the test has teeth. - Pin behaviour before code is reshaped. - Let the full toolchain run with its config intact.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.