Sub topic 9
Verifying with your own checks, not the agent's summary
This chapter assumes you can run your project's tests, linter, type checker, and build from the command line. It also assumes you have a clean baseline and a triaged diff, as covered in the earlier chapters. The goal here is to confirm the change works by running checks yourself.
Why the summary is not evidence
When an agent finishes, it writes a summary. The summary says what the agent intended and what it believes it did. It is not a record of what happened. Three things can make it wrong:
- The agent may report a test run it never performed, or one that ran a narrower set of tests than you assume.
- The agent may have run the checks before its last edit, so the result describes older code.
- The agent may describe the plan it followed while the diff shows something different.
Treat the summary as a list of claims to test. "All tests pass" is a claim. "No behavior changes" is a claim. You check each one with a command whose output you read yourself.
The verification ladder
Run checks from cheapest to most expensive. Early failures are quick to read and usually point to a specific line.
- Syntax and import check. Does the code load at all?
- Linter. Does it follow project style and catch simple bugs?
- Type checker. Do the changed signatures agree with every caller?
- Unit tests. Does each changed piece behave correctly?
- Full test suite. Did anything unrelated break?
- Build. Does the project package or compile?
- Running the code. Does the real behavior match the task?
Each rung catches a different kind of defect. The type checker finds a renamed function that one caller still uses by its old name. Tests find a changed return value. Only running the code finds a feature that passes every test but does not do what you asked.
Run the checks on a clean state
Results are only trustworthy if the code under test is the code you will commit. Before you run anything, confirm what is in the tree and remove stale artifacts that can hide failures.
git status --short
git diff --stat
find . -name "__pycache__" -type d -prune -exec rm -rf {} +
rm -rf .pytest_cache .mypy_cache .ruff_cacheStale caches and compiled files can make a deleted module appear to still exist. In some projects, leftover build output makes a broken import succeed. Clearing caches costs seconds and removes a class of false passes.
If the agent installed new dependencies, check that too. A change that passes only because the agent ran pip install in your environment will fail for the next person.
git diff --name-only -- requirements.txt pyproject.toml package.json package-lock.jsonAny change to a dependency file deserves its own review. It was probably not part of the task.
Run the project's own commands
Use the commands the project already defines, not ones the agent chose. If the agent ran pytest tests/test_loader.py and your continuous integration (CI) system runs pytest, only the second one counts. Look in the Makefile, package.json scripts, or CI configuration for the real commands.
ruff check .
mypy src
pytest -qReplace these with your project's tools. The exact commands matter less than using the same ones CI will use. Keep the exit codes in view, because a command that prints warnings can still fail.
ruff check . && mypy src && pytest -q
echo "exit code: $?"The && operator stops at the first failure. The final echo prints 0 only if every command succeeded.
Check that the tests actually exercise the change
A green test run says little if no test touches the changed code. Coverage output tells you whether the new lines ran.
pytest -q --cov=src --cov-report=term-missingLook at the Missing column for the files the agent changed. Lines listed there never ran during testing. If the agent added a new branch and every line of it is missing, nothing verifies it, and you need either a new test or a manual check.
A second technique is a deliberate break. Introduce a small bug in a changed function, such as flipping a comparison, and run the tests. If they still pass, they do not cover that behavior.
git stash list
sed -i.bak 's/>= 0/> 0/' src/config/loader.py
pytest -q
mv src/config/loader.py.bak src/config/loader.py
git diff --statThe last line confirms the file is back to the agent's version. Do this only on a branch where you can undo it. Run git diff afterward to make sure nothing remains from the experiment.
Check behavior the tests cannot see
Some changes are invisible to tests. A renamed command-line flag, a changed log format, a new default value, and a different error message can all pass the suite and still break users. Compare the program's behavior before and after.
A reliable pattern is to run the same command on the baseline commit and on your working tree, then compare output.
git stash push --include-untracked -m "agent work"
python -m myapp --config sample.toml > before.txt 2>&1
git stash pop
python -m myapp --config sample.toml > after.txt 2>&1
diff before.txt after.txt && echo "no output difference"Any difference is either an intended change or a silent behavior change. For a refactor, expect no difference. If the task was a rename, the output should be identical.
For a public interface such as an HTTP API, call it by hand or with a small script and read the response. Check the unhappy paths as well: a missing file, an empty input, a malformed value. Agents tend to verify the main path and skip these.
Type checks and what they prove
A type checker confirms that names and signatures agree across files. This is the strongest automatic check for a multi-file change, because the failure it catches is the one this kind of change is most likely to cause. Run it on the whole project, not only the changed files. A signature changed in one file breaks callers in others.
mypy src testsBe careful with # type: ignore, Any, and cast. An agent can make an error disappear by adding one of these. You looked for them during test integrity checks, and you should search again after the final run.
git diff -U0 | grep -nE '^\+.*(# type: ignore|# noqa|cast\(|: Any)'What a pass does and does not prove
| Check | What a pass shows | What it does not show |
|---|---|---|
| Linter | Style and simple bug patterns are clean | The logic is correct |
| Type checker | Names and signatures agree | Values are correct |
| Unit tests | Tested behavior still holds | Untested behavior is unchanged |
| Full suite | No tested regression elsewhere | The feature does what you asked |
| Build | The project assembles | The built program behaves correctly |
| Manual run | The scenario you tried works | Scenarios you did not try |
No single check settles the question. Confidence comes from several independent checks agreeing, plus your own reading of the diff.
Common errors in verification
- Trusting the agent's test output. Re-run it. Output pasted into a summary can be from an earlier state.
- Running a subset. A targeted test run passes while the full suite fails. Always finish with the full suite.
- Ignoring skipped tests. Read the summary line.
120 passed, 9 skippedis different from120 passedif the skips are new. - Verifying in a different environment. Your machine may have packages or environment variables that CI lacks. Prefer a clean virtual environment or container when a dependency changed.
- Stopping after green. Passing checks mean you found no problem. They do not mean there is no problem. Read the risky parts of the diff after the run, and run the code.
Recording what you verified
Keep a short record of each run in your commit message or review notes. It lets you or a teammate know what was and was not covered.
Verified on branch agent/rename-config-loader at commit 3f9a1c2:
- ruff check . exit 0
- mypy src tests exit 0
- pytest -q 118 passed, 0 skipped
- Manual: python -m myapp --config sample.toml, output identical to baseline
Not verified: Windows path handlingThe final line is as useful as the others. Writing down what you did not check keeps a gap from becoming a false assumption later.
When verification fails
A failure is information. Read the first error, not the last, because later errors often follow from it. Decide which kind it is:
- The agent's change is wrong. Send specific feedback naming the failing command and the error, as covered in the steering chapter.
- The test was already failing on the baseline. Run the same command on the baseline commit to find out, then keep that failure separate from the agent's work.
- The test is flaky. Run it several times before blaming the change.
git stash push --include-untracked -m "agent work"
pytest -q tests/test_loader.py
git stash popIf the test fails on the baseline too, the agent did not cause it.
Exercise
An agent reports "All tests pass, no behavior changes" after renaming a function across eight files. You run the full suite and it passes. List three further checks you would run before accepting the change, and say what each one catches that the test suite does not.
Show answer
1) Run the type checker on the whole project. It catches callers that still use the old name or signature in code paths no test exercises. 2) Run the coverage report and read the Missing column for the changed files. It shows whether any changed line ran during the tests, so a green suite is not hiding untested code. 3) Run the program on the baseline and on the working tree with the same input and diff the output. It catches behavior changes that no test asserts, such as different log text, flags, or defaults. Searching the diff for added skip, xfail, noqa, and type: ignore markers is also a reasonable answer.
Exercise
The agent's summary says it ran pytest and everything passed. When you run pytest, 4 tests fail. What are two possible explanations that do not involve the agent lying, and how do you tell them apart?
Show answer
The agent may have run the tests before its final edit, or it may have run only a subset of tests. Another possibility is that its environment differs from yours, for example a locally installed package. To tell them apart, run the same command on the agent's commit in a clean environment. Then run the failing tests on the baseline commit. If they fail on the baseline, they were already broken. If they pass on the baseline and fail on the agent's tree, the change caused the failures.