Our LLM agent retried the same browser rehearsal 58 times because our validator returned passed: false with an empty errors list. With no reason given, it changed things at random. We fixed it by turning the false failure into a structured warning that names the fix, capping repeat attempts on flags the agent can't clear, and adding a circuit breaker.
The agent is a Claude tool loop. It explores a live web app in Playwright, writes a narrated demo scene, and must call propose_and_rehearse_scene until a real headless rehearsal returns a passing report. Each rehearsal replays the whole scene and takes 30 to 60 seconds or more. We already wrote up the cost side of this system in how we cut an LLM agent job from 60 min / $7 to 9 min / $1.67. This post covers only the feedback contract between the validator and the agent.
What did the failing rehearsal report look like?
Every action passed. A scene-level boolean still said the scene failed, and nothing explained why. One "pausable" action had a visual-settle measurement marked degraded: true, reason: "timeout" because a product page ran an animation that never stopped. The validator set passed = False for that and never wrote an error.
The report shape below uses the exact field names our rehearsal module produces. The action names and values are illustrative:
{
"passed": false,
"errors": [],
"actions_validated": [
{"name": "open_product", "ok": true},
{"name": "start_tryon", "ok": true,
"settle": {"degraded": true, "reason": "timeout",
"duration_ms": 8000,
"proposed_settle_timeout_ms": 12000}}
],
"pausable_measurements": [ ...same settle object... ]
}
The offending code was a single line inside the settle-measurement branch:
if result.degraded:
report["passed"] = False # no error, no warning, no advice
A human reading that report would eventually spot the degraded flag buried in a measurement. The agent read the top of the report, saw passed: false, found nothing in errors, and decided something in its scene was wrong.
Why does an LLM agent retry blindly when the errors list is empty?
When a tool says "failed" and gives no reason, the agent can't diagnose anything, so it guesses. It rewrites selectors, reorders actions, adds waits, and tries again. Each guess costs a full rehearsal. None of them could work in job 0e04afe3, because the scene was fine and the page simply never went still. The agent made 58 blind retries.
The agent didn't behave irrationally. Its system prompt said, correctly, never to hand back a scene without a passing report. It was optimizing for a signal it had no way of moving. Anthropic's own tool-design guidance warns about this. It says to prompt-engineer error responses to communicate specific and actionable improvements, rather than opaque error codes. A bare passed: false is the most opaque error code there is.
The rule we took away: a validator that hands an agent a negative verdict must also hand it a reason it can act on. passed: false with errors: [] is a bug in the validator, not a state the agent should be left to work out.
When should a failed check be a warning instead of an error?
Ask whether the agent changing its output could ever change the result. A perpetual animation never settles, whatever the scene says, and the real recording already tolerates it: the take resumes after a safety margin. A selector that never matches can be fixed by the agent. The first is a warning; the second is a hard error.
Our first fix (fix 1) downgraded the degraded settle to a warning and wrote the remedy into the warning text, naming the exact fields the agent can change. We had evidence the downgrade was safe: a delivered production video had already shipped with degraded_pause_count=1 and looked fine.
A follow-up found that some "degraded" timeouts weren't animation at all. In those cases, the next action's target selector never resolved during the settle window. A checkbox sat inside an iframe that the readiness check never looked into. In the report, a slow page and a missing target looked identical. So we split the two cases on one extra measurement field, target_ever_resolved:
if result.degraded and result.target_ever_resolved is False:
report["errors"].append(
f"pausable action {name!r}: its NEXT action's target selector "
f"never resolved even once during the full "
f"{int(result.duration_ms)}ms settle window (tried the top-level "
f"document and every iframe on the page) -- this is not a "
f"slow-settle timeout, the target genuinely could not be found. "
f"Fix the selector (or the action ordering) before this scene "
f"is rehearsal-eligible."
)
report["passed"] = False
elif result.degraded:
report.setdefault("warnings", []).append(
f"pausable action {name!r}: page never fully settled within "
f"{int(result.duration_ms)}ms (reason={result.reason!r}). The take "
"will still work (degraded pause + safety margin), but if a region "
"is perpetually animating, add a mask_rect for it or raise "
"settle_timeout_ms."
)
Both branches carry a message that names a concrete next action: fix the selector, or add a mask_rect or raise settle_timeout_ms. The passed = False line now appears only next to an appended error. That pairing is the invariant to keep.
Why did the agent still rehearse 95 times after the report was fixed?
The report and the system prompt disagreed. Fix 1 made a degraded settle a warning, but step 5 of the agent's instructions still listed "any pausable action's settle is degraded: true" as a must-fix-and-rehearse-again trigger. In job f1efd525, two degraded flags on a continuously animating try-on modal kept the agent rehearsing about 95 times over roughly 50 minutes.
That is a contract bug spread across two files. The validator's severity model lives in code, and the agent's reading of severity lives in the prompt. Changing one without the other leaves the agent obeying its instructions while the instructions contradict the data. We wrote about the general version of this failure in prompt engineering as semantic contracts for fixing silent failures in multi-step LLM pipelines.
The fix removed degraded from the must-fix trigger list and added a bounded two-strike rule to the prompt. This is the actual instruction text, trimmed:
- Strike 1: the first time an action comes back `degraded: true`,
read that same measurement's `proposed_settle_timeout_ms` and set it
as a `settle_timeout_ms` override on that action. Fix anything ELSE
the report flagged in the same revision (never a degraded-only
rehearsal), then rehearse again.
- Strike 2: if the SAME action comes back `degraded: true` AGAIN, with
the override already applied, that is the site's real steady-state
behavior. ACCEPT it. A degraded settle does NOT block `passed`.
This is explicitly NOT a license to ignore real problems: an action
with `error` set, or a report with `passed: false`, remain must-fix.
Strike 1 matters because some degraded settles really are timeouts that are too tight. The report already measures how long settling actually took and proposes a realistic value, so the agent gets one well-informed retry. If the flag survives that, it was never fixable.
How does a repeat-failure circuit breaker work for an LLM agent in 2026?
Our breaker tracks a signature for each failure: kind, action name, and error text or reason. It counts consecutive rehearsals in which each signature appears. After three identical repeats, it adds a repeat_failure_note to the tool result telling the agent that rehearsing the same approach won't help. It adds information; it doesn't end the job.
The prompt rule is the policy. The breaker is a mechanical backstop for when the model drifts from that policy late in a long context. The core of it, as it runs inside our propose_and_rehearse_scene tool:
_breaker_state = {"consecutive_counts": {}, "attempt": 0}
_REPEAT_FAILURE_THRESHOLD = 3
def _failure_signatures(report: dict) -> set[tuple]:
sigs = set()
for key in ("actions_validated", "pre_actions_validated"):
for entry in report.get(key) or []:
name = entry.get("name")
if entry.get("error"):
sigs.add(("error", name, str(entry["error"])))
settle = entry.get("settle")
if settle and settle.get("degraded"):
sigs.add(("degraded", name, str(settle.get("reason"))))
return sigs
# after each rehearsal:
current = _failure_signatures(report)
counts = _breaker_state["consecutive_counts"]
for sig in list(counts):
if sig not in current:
del counts[sig] # streak broken: start over at 1 next time
for sig in current:
counts[sig] = counts.get(sig, 0) + 1
repeated = {s: n for s, n in counts.items() if n >= _REPEAT_FAILURE_THRESHOLD}
if repeated:
result["repeat_failure_note"] = (
"These have failed identically N times in a row -- rehearsing an "
"unchanged approach again will NOT fix them: ... For degraded "
"timeouts, follow the two-strike rule ... For errors, change "
"strategy (different selectors/actions/action kind) instead of "
"re-rehearsing the same approach."
)
Three design choices matter here. Signatures are tracked separately for errors and degraded flags, so a fix that clears one doesn't reset the other's streak. A streak resets as soon as a signature is missing from an attempt, because a failure that comes back after a real change counts as a new occurrence. And the note goes into the tool result, which is where the model reads it on its next turn.
We chose a nudge over a hard abort on purpose. Aborting after N identical failures would kill jobs where the agent was one strategy change from a passing scene, and a "complete" scene that was really a truncated one is worse than a slow job. The note says exactly what to change. A hard abort would only say stop.
Why must a failing report be returned to the agent instead of raised?
Our rehearsal subprocess exits with code 1 in two cases: when it crashes, and when the scene fails after writing a complete report. The wrapper treated both as crashes and raised, so the agent got a generic pipeline error instead of the report's per-action errors. Same empty-feedback bug, one layer down.
The fix accepts exit 1 and then returns the report if it is fresh, meaning its mtime is at or after the moment the subprocess started. It raises only when no fresh report exists. The freshness check matters: a crash can leave a stale report from an earlier attempt on disk. The full snippet is in the cost write-up linked at the top of this post, so we won't repeat it here.
We also started emitting a rehearsal_result event for every attempt, including aborted ones: attempt number, passed, up to five truncated errors, degraded action names, and whether the breaker fired. Before that, our logs showed only that the tool had been called, not what it returned. We could see a loop but not why it was happening.
How many rehearsals should an agent need per scene?
A handful. Job 82acb18f spent 38 of its 56 loop minutes on 56 full-scene rehearsals because the agent built the scene step by step: add one action, rehearse everything, add the next, rehearse again. A prompt rule to draft the complete scene first and then fix all flagged problems in each revision removed that pattern.
This is the instruction we added, trimmed:
Do NOT build the scene incrementally (add one action, rehearse, add the
next, rehearse again). Finish your exploration FIRST, write the COMPLETE
scene in one draft, and only then rehearse it. Use each subsequent
rehearsal solely to fix what the previous rehearsal's report actually
flagged, and fix ALL flagged problems in one revision per rehearsal,
never one-at-a-time. This is a wall-clock/efficiency rule, not a quality
waiver: "complete first draft" means complete coverage of the brief, not
a thinner scene to make rehearsals easier.
The last sentence carries weight. Any rule that rewards fewer rehearsals also rewards a thinner scene that is easier to pass. We had already caught an agent passing rehearsal with a degenerate scene, so the efficiency rule repeats that the anti-reward-hacking rule still applies in full.
Batching fixes only works if the report lists everything that went wrong, not just the first failure. The changes above lead here. Once every failing verdict comes with an actionable reason, an agent can fix all the problems in one revision instead of finding them one rehearsal at a time.
What is the complete fix for blind agent retry loops?
There are six parts. Never return a failing verdict without an actionable reason. Grade severity by whether the agent can change the outcome. Keep the prompt's severity rules identical to the validator's. Limit unfixable flags with a strike count. Detect identical consecutive failures and tell the agent to change strategy. Always return failing reports instead of raising them.
- Invariant:
passed: falseimplies a non-emptyerrorslist. Check for this in review or with an assertion at the end of the report builder. - Severity: if no change to the agent's output can clear a check, report it as a warning and name the knob that helps (
mask_rect,settle_timeout_ms). - Split ambiguous signals: "slow" and "never found" both looked like
degraded: true. One extra field,target_ever_resolved, made one a warning and the other an error. - One contract, two files: whenever the validator's severity changes, update the prompt's must-fix list in the same commit.
- Bounded retries: two strikes on unfixable flags, plus a three-repeat breaker that adds guidance instead of aborting.
- Observability: log every attempt's outcome, not just the fact that a call happened.
The 58-retry and 95-retry loops weren't model failures. Our validator and our prompt gave the agent a target it couldn't reach and no information about why. An LLM agent can only be as precise as the feedback it gets, so when it retries blindly, check the tool contract before you change the model or the prompt wording.