r/AI_Loops • • 5d ago

A Claude Code agent setup measured its own failures: 39.6% of subagent handbacks were rejected, and the bug was in the instructions, not the model

u/a4mula shared this in the comments here last week and agreed to let me write it up. It's the most concrete example I've seen of an agent setup that measures its own failures, and his own caveats are kept below.

The setup

A multi-agent Claude Code system with different agent "seats" (a main seat, workers, Explore, an adversarial reviewer, workflow subagents and so on), hooks that validate what each one hands back, and a session-open packet that loads the knowledge each seat needs.

The loop

  1. Record: every tool call is logged with its outcome: ok, tool error, or blocked by a hook
  2. Evaluate from outside: an evaluator that isn't one of the agent seats reads that telemetry read-only (SQLite opened mode=ro). It runs every 10th session, or after any session with a failed-tool-call rate above 10%
  3. Look for specific patterns: failure rates by seat and tool, hooks that never fire, retry loops (the same failure repeated on one command), and gaps in the session-open packet, meaning things the agent didn't know it didn't know
  4. Fix the instructions, not the agent
  5. Measure again

What it found

He backfilled outcomes onto about 17.8k historical tool calls. About 300 were subagent handbacks rejected by a hook for returning the wrong JSON shape. Cross-reading the rejections against the schemas showed that one helper instruction template listed the return keys but left out one the schema requires. Another template still said a field was "not checked" long after the hook started checking it, and that accounted for 43 more.

His point: the agents were following their instructions faithfully. The rejection message told them what was wrong, but the instructions had never told them what was required. The gap was in the instructions.

Before and after (template fixes landed 2026-11-23)

  • Handback rejections: 299 of 755 (39.6%) from 11-11 to 11-21, then 9 of 52 (17.3%) on the day of the fix
  • StructuredOutput errors: 176 of 388 (45%) before, 5 of 14 (36%) after. Too few calls to tell apart

His caveats

  • The after sample is one partial day
  • The rate was already falling before the fix: 47% on 11-19, 22% on 11-20, 29% on 11-21, because the hook started validating handbacks on 11-19. The template fix can't take all the credit
  • 17.3% is not near zero, so the instructions are still missing something, and the by-reason breakdown hasn't been re-run yet

What I'd take from it

  • When a hook keeps rejecting the same thing, assume the instructions are wrong before assuming the model is
  • Diff every instruction template against the schema and hook it points to. That's cheap and it's the automated version he's building next
  • Keep the evaluator outside the agents and read-only, so it can't change what it measures

Anyone else measuring failure rates per agent role? What does your worst seat/tool pair look like?

3 Upvotes

0 comments sorted by