Lesson 10.04 · Phase 10 · Coding & Computer-Use Agents
Test-driven agent loops
Tests are the only reward signal a coding agent gets that isn't its own opinion. So protect them. Run them after every change and feed back a compact, structured failure report. Make test files read-only so "fix the tests" isn't an option. Stop when the failures stop changing. And require a new test to fail before the fix, or it proves nothing.
Learning objectives
- Run tests through a JSON-producing runner and give the model a compact failure report instead of raw output.
- Make test files read-only to the agent, and detect tampering by hash even if it gets through another way.
- Stop the loop on "no progress" (same failures N rounds in a row), not only on a round budget.
- Check that a new test fails on the current code before accepting it as evidence of a fix.
You give an agent a failing test suite and a loop: edit, run, repeat until green. It gets to green. Then you read the diff. Half the "fix" is in testslug.py, where it changed the expected value to match what the code returns. Models trained to make tests pass sometimes learn exactly this, and frontier labs have reported it: models special-casing tests, or editing tests, to get a pass.
Loading the full lesson…