Cheat sheets

Why Agents Fail

Name the failure, find it in the trace, gate it. Detectors, MAST, retry storms, PVE and a trace debugger.

  • Concepts and terms
  • Tasks and commands
  • Annotated code
  • Diagrams
  • Comparisons
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Symptoms, causes, fixes#

SymptomCauseFix
Success message on a 400 errorSuccess hallucinationRe-probe state. Was the file actually created?
One wrong call triggers four API callsCascading errorAutomated verification gates at every step
Downstream load goes to 10xRetry stormCircuit breakers and capped retry budgets per request
Gradual accuracy decay, no crashMemory poisoningAppend-only log, provenance, unwritable verifier
Three agents give the same wrong answerMonoculture collapseUse diverse prompts and/or models
Two agents both think they are the reviewerRole ambiguityExplicit role contracts and acceptance tests per task
Agent A thinks done, agent B still runsState driftVersioned shared state, state-sync checkpoints
Retrieved page overrides the developer promptIndirect prompt injectionTreat all retrieved content as untrusted. Add PVE

Five recurring modes and their detectors#

CommandWhat it does
detect_hallucinated_actionTool name not in KNOWN_TOOLS
detect_scope_creepwrite_file call with no write word in the request
detect_cascading_errorsAn error, then 2 or more tool calls after it
detect_context_lossA "do not" token appears in tool args
detect_tool_misuseRequired args missing for the tool schema
detect_success_hallucinationSuccess claim, write intent, state unchanged
tag(trace)Runs all DETECTORS, returns the labels
python3 code/main.pyPer-trace labels and aggregate distribution

MAST root categories#

Source
1642 execution traces, 7 open-source MAS, 41-86.7% failure rate.
Specification Problems (41.77%)
role ambiguity, unclear task, implicit success criteria.
Coordination Failures (36.94%)
lost messages, unsynchronized shared state, state drift.
Verification Gaps (21.30%)
one agent claims success and no one verifies.
Cost
verification gaps are the most expensive per failure. They fail silently.
Code
categorize_incident(symptoms) returns spec, coord, verify or unknown.

Groupthink family#

Monoculture collapse
same base model gives correlated errors. Signal correlated_errors.
Conformity bias
agents align with the loudest peer. Signal agreement_rate_spike.
Deficient ToM
agents cannot model each other. Signal coordination_drop_long_horizon.
Mixed-motive dynamics
compromise-middle satisfies no one. Signal compromise_outputs.
Cascading reliability failures
one error pattern triggers others. Signal retry_amplification.
STRATUS
detection, diagnosis and validation agents. 1.5x mitigation success.

Retry storm#

1Payment servicefails 10% of requests.2Order agenteach retry is a new order-inventory check.3Inventory servicesees 2x normal load and starts timing out.4Every orderretries. Inventory sees 10x load. Cluster goesdown.5Fixa circuit breaker short-circuits with cached ordefault results.

Circuit breaker and storm simulator#

breaker = CircuitBreaker()starts BreakerState.CLOSED
breaker.allow()False while OPEN, inside cooldown
breaker.record(ok)opens when error rate > threshold
HALF_OPEN: one success closes, one failure opens again
service = DownstreamService()base_failure_rate 0.1
effective_rate = self.base_failure_rate + (self.load * 0.02)
while attempts_for_req < 4:retry budget per request
...
simulate_retry_storm(200, use_breaker=True, seed=0)
returns total_calls, successes, short_circuits

Defaults and numbers#

SettingDefaultNote
failure_threshold0.5Error rate that opens the breaker
window_size20Recent outcomes in the error rate
open_cooldown_s0.5Time before HALF_OPEN
Production open threshold5-10%Error rate on each outbound call
CI trace gate>=5%Lesson exercise. Fail the build when traces tag a mode
Audit trace sample~1000Real traces per failure-mode audit
Debate N, RN=3, R=2Original experiments, due to cost

PVE: Prompt-Validator-Executor#

intentscannedcandidate callallowrejectretryclientUser messagesourceuser_messagestoreRetrievedcontentweb, memory,tool outputmodelMain modelproposes aToolCallprocessValidatorallowlist +marker scanprocessExecutorruns approvedcallRefusaltry a differentapproachintentscannedcandidate callallowrejectretryclientUser messagesource user_messagestoreRetrieved contentweb, memory, tooloutputmodelMain modelproposes a ToolCallprocessValidatorallowlist + markerscanprocessExecutorruns approved callRefusaltry a differentapproach

Debate topologies#

FactorFull meshSparse star
Who reads whomEvery debater reads every peerSpokes read only the hub
N=5, R=3 proposals1515
N=5, R=3 critique ops6012
Failure riskConvergence collapseHub failure
MitigationRequired disagreement roundsRotate or use multiple hubs
Codefull_mesh_roundsparse_star_round

Agent Trace Debugger#

TaskCode
Init the workspacepython3 scripts/project_test.py agent-trace-debugger --init learning-artifacts/agent-trace-debugger
Grade one stagepython3 scripts/project_test.py agent-trace-debugger --stage 1 --path learning-artifacts/agent-trace-debugger --strict
Compare to a baselinenode cli.ts --input samples/trace.jsonl --baseline samples/before.jsonl --output trace.html --json trace.json
Import OTLP JSONnode cli.ts --format otlp --input samples/otlp.json --output otlp-trace.html --json otlp-trace.json
Public APIparseTrace, validateTree, unionDuration, analyze, render
Regression fieldswall_time_delta_ms, token_delta, error_delta

Trace debugger errors#

SymptomCauseFix
invalid JSON line <n>Line is not JSONFix line n. Blank lines count
invalid span line <n>Bad field, end < start or negative tokensEmit ok or error and finite times
duplicate span idTwo spans share an idMake ids unique
span cycleAncestor chain loopsFix the parent ids
missing parentParent id not in the traceExport the parent span
child outside parentChild interval exceeds parentNormalize cross-machine clocks
format must be jsonl or otlpBad --format valueUse jsonl or otlp

Questions#

Why is tagging only crashes not enough?
Most agent failures produce valid-looking output.
Why not guardrails at the end only?
The model already touched the world.
Which slow-failure proxies help?
Agreement rate, retry rate, output-length distribution.
Why subtract the union of child intervals?
Parallel children overlap. Their sum overcounts.
Why compare tokens and errors, not only wall time?
The sample keeps 100 ms while tokens rise by 200.