AI Engineering · interactive
Why agents fail
An agent that gets each step right 95% of the time sounds reliable. Over 20 steps it finishes the task about a third of the time. Watch 20 runs of the same task, see how each one broke, and add the safeguards that catch each kind of slip.
20 runs · 20 steps each
7/20 finished
- 1✓
- 2✗
- 3✗
- 4✓
- 5✓
- 6✗
- 7✗
- 8✗
- 9✓
- 10✗
- 11✓
- 12✓
- 13✗
- 14✗
- 15✗
- 16✗
- 17✗
- 18✓
- 19✗
- 20✗
- step ok
- slip caught, redone
- wrong tool
- bad arguments
- lost the goal
- stuck in a loop
7 of 20 runs succeed (36% expected). Turn on the safeguards in step 4.
Steps in the task
Break the task into steps
Booking a trip is search, compare, pick, fill a form, pay, confirm. Each step is a model call and a tool call, and the run only succeeds if every step does.
20 steps · all must succeed
Every step can slip
Most steps work. The ones that don't fail in a few typical ways.
- Wrong tool 30% of slips · 4 runs hereCalls search when it should call the booking API.
- Bad arguments 30% of slips · 4 runs herePasses a date as “next Friday” or a made-up booking id.
- Lost the goal 20% of slips · 2 runs hereAfter many steps it optimizes for a side detail and forgets the task.
- Stuck in a loop 20% of slips · 3 runs hereRepeats the same call, gets the same result, tries again.
Small slips compound
The chance of getting every step right is the per-step chance multiplied by itself once per step. Long tasks need very reliable steps.
Catch slips where they happen
Each safeguard catches one kind of slip some of the time. A caught slip costs a retry instead of the run.
Check arguments against the schema and return tool errors to the model as observations, so it can retry.
The agent keeps a short to-do list in its context and checks each step against it.
Spot the same call with the same arguments twice, tell the model, and stop the run at a hard step limit.
each step ends well: 95% → 95%
Cap the run, and count
A loop with no cap runs until someone kills it: here, 40 steps of paid model calls. Cap steps and spend, and measure success over many runs, not one demo.
- Runs that finished
- 7 / 20
- Expected over many runs
- 36%
- Steps burned by loops
- 98
Shorter tasks help as much as better steps: split a 30-step job into checked stages, or hand the risky step to a person.
In production
Tools and technologies
Agent frameworks give you the safeguards; tracing and repeated-trial evals tell you how often runs actually succeed.
Not tied to one language — use these names when you search docs or design a system.
- τ-benchStandard
Measures pass^k: does the agent succeed every time, not just once.
GitHub ↗ - LangGraphSoftware
Agent graphs with checkpoints, retries and a recursion limit.
GitHub ↗ - OpenAI Agents SDKSoftware
Agents with guardrails, handoffs, max turns and tracing.
GitHub ↗ - LangfuseSoftware
Traces every step of a run, so you can see where it went wrong.
GitHub ↗ - Building effective agentsStandard
Anthropic: keep agents simple, add checks, prefer workflows when you can.
Official site ↗