The overnight agent loop needs a half that stops, and a rule against well-reviewed fences
Cristiano Mazzella on his own overnight harness: a read-only verifier that records the command it ran, three deliberate ways for a run to stop, and why a rigorous, green, reviewable workaround can still be the wrong change.
Source: How I run a coding agent overnight without waking up to 8 hours of retries
Cristiano Mazzella's write-up of his overnight harness starts from a split he sees in every discussion of agents that run while you sleep: some people wake up to real shipped work, others to an unmaintainable diff and a runaway bill. His read is that both are describing the same gap. The tooling that starts a loop is mature, and the half that stops it mostly isn't there.
In his harness, work is broken into phases stored as files, each with a done condition a command can check. An iteration ends in one of four ways, and three of them are stops:
- The phase closes, but only on a verifier's word. A separate read-only agent with its own context runs the done check and returns pass or fail with the command it ran. Mazzella calls this the part he'd keep if he threw everything else away. An agent that grades itself overnight will eventually call something finished that isn't, the next iteration builds on that claim, and by morning you are reading "a summary of a summary" with the first wrong link three iterations back.
- It hits an authority edge. Merges, protected paths, schema changes and new dependencies get written up and blocked, and the loop moves to the next independent phase.
- No progress twice. The second time an iteration ends where it started, the phase blocks and the run pauses. That turns eight hours of retries on one wedged step into one blocked phase, but only when done conditions are checkable; with a vague one, every iteration looks like progress.
- Only human rulings remain. It stops and lists them, which counts as a correct ending. A loop allowed to invent scope to keep running will do exactly that.
A green fence is still a fence
The sharpest part for reviewers is a failure that passed every gate. An agent found a defect in code it was passing through, wrote a 20-line comment explaining it, added a test watching it, and filed a ticket. The fix already existed elsewhere in the repo. The test now guaranteed the bad code stayed put. Mazzella traces it to his own instructions: the done condition allowed either fixing or declaring the debt, and declaring closes the phase tonight. His rule against chasing new scope also protected every defect on the path. Nothing in a diff says "well-built cage around something that should have been deleted," so no gate he owned would catch it. The rule became a workflow: one agent maps every place using the old form along with a command that counts them, separate fixers each own their files, and a verifier re-runs the count.
He also moved decisions out of a carefully kept docket nobody opened and into one-line chat questions with a default and the cost of not answering. A loop that runs all night only keeps moving if its human answers the few questions it actually needs. These are one practitioner's results on his own work, with evals he hasn't published yet.