Why your agent fails long tasks (and the gate that fixes it)
A short breakdown from Adam Rosler. The thing you commented GATES for.
What's happening
Every step an agent takes is a small bet, and the bets multiply. Picture a marble run with twenty stations where each station lets 95 marbles in 100 through. After twenty stations, about 36 are left (0.95^20 = 0.358). Make every station better, 98 in 100, and you still lose one marble in three (0.98^20 = 0.668). That's a simplified picture (real steps aren't independent coin flips), but it's why long tasks feel so much worse than short ones.
The best public measurement points the same way. METR, a research lab that times AI agents on real software work, found that the length of task frontier models finish half the time has doubled about every seven months since 2019. But the tasks they finish four times out of five are 4-6x shorter. In the paper's words, even models that sometimes succeed on hard tasks "cannot reliably perform tasks of moderate length" (Kwa et al., Measuring AI Ability to Complete Long Software Tasks, arXiv 2503.14499).
The cruel part: a mistake doesn't stay where it happens. Step 13 takes step 12's output as its input, so one wrong guess rides along into every later step, and nothing in the agent stops it.
Why it matters
I tested it (23 Nov 2026): a 20-step data task (a bank's CSV export turned into a quarterly report, step01 …
step20, each step feeding the next), run 16 times in Claude Code with the same model, ticket and data.
| Runs | All 20 steps matched the bank's figures | |
|---|---|---|
| No checks | 8 | 0 of 8 (the best run: 19 of 20) |
| A test after every step (the gate) | 8 | 8 of 8 |
The misses were ordinary. At step 12, one run decided "a tip isn't a person", so it didn't split a "city taxi / tip" payment, and every step after built on that guess. With the gate, every run tripped at least once (step 12 in all eight), saw the failure straight away and fixed it before moving on: 13 slips caught and sent back.
A smarter model makes each station a bit better. A gate stops a slip from travelling.
What to do
Put a gate after every step:
- Test every step. One small check per step with the real expected output. If you can't write the check, the step is too big: split it.
- Send a failure straight back. The agent should see the failing check the moment it writes the step, and fix that step before it writes the next one. It shouldn't be able to finish while anything fails.
- Every ten steps, it stops for you to look. A checkpoint where it summarises what it built and waits for your OK, so your attention goes where the risk is, not on every keystroke.
In Claude Code, that's one hook in your project settings: a PostToolUse hook that runs the step's check after every
edit (exit code 2 sends the failure back to the agent) and a Stop hook that refuses to stop while a check fails. The
full hook I used, with the settings and a test template, is here: gate.py and guide.md.
My rule: if you can't check a step, it's too big.
Sources: Kwa et al. (METR), "Measuring AI Ability to Complete Long Software Tasks", arXiv 2503.14499 (§3.2.1 for the 80 % horizon). The 16 runs are my own, in Claude Code on 23 Nov 2026; the gate hook and its test are on this page.
Files for this breakdown
gate.py- The step gate: stop your agent's long tasks falling apart (the one-pager)
Unlock the full GATES breakdown + downloadable runnable scripts
Drop your email once to read the complete step-by-step guide, grab the files, and unlock all 96 Reel breakdowns on this device forever.