Why agents fail
7 min read
Errors multiply
Suppose each step of an agent succeeds 95% of the time. That sounds reliable. But a task of ten steps succeeds only when every step does, so the chance of success is 0.95 multiplied by itself ten times.
for steps in (1, 5, 10, 20):
print(steps, round(0.95 ** steps, 2))The output is 0.95, 0.77, 0.6 and 0.36. At twenty steps, the agent fails nearly two times in three. The lesson is not to give up. It is to keep tasks short, to check results between steps and to stop an error before it feeds the next step.
- 1 step95%
- 5 steps77%
- 10 steps60%
- 20 steps36%
Five failure patterns
Most real failures fall into five groups.
- A wrong tool or wrong arguments. The model picks a tool that looks right but is not, or passes a bad value. Better tool descriptions and validation reduce this.
- A false claim of success. The agent says "done" when the work is not finished. A check in code, not in the model's words, catches it.
- A loop. The agent repeats the same action and gets the same result. A step limit and a repeat detector stop it.
- Lost context. The history was trimmed or grew too long, and the agent forgot the goal or a constraint. Pin the goal and keep the history small.
- A bad source. The agent trusted a wrong page or a stale file and built on it. An AI hallucinationAn answer that sounds confident but is false. The model wrote text that fits the pattern instead of text that is true. can also fill a gap when the facts are missing.
Each pattern has a different fix. If you treat every failure as "the model is not smart enough", you will buy a bigger model and still see the same errors.
Read the trace, not the answer
When an agent gives a wrong final answer, the cause is usually several steps earlier. Read the trace from the start and find the first step that went wrong. That step is the root cause. Everything after it is a consequence.
Ask three questions at that step.
- What did the model see in its prompt?
- What did it decide, and why was that reasonable given what it saw?
- What check could have caught it?
The third question gives you the fix. It is usually a validation, a limit or a clearer tool, and it often comes to a few lines of code.
Design for the failure you expect
You cannot remove failures, so plan for them. Keep tasks short. Verify results with code where you can. Give the agent a way to say "I am stuck". The next two Lessons turn these ideas into tests and guardrails.
How likely is success?
Each step succeeds 95% of the time, and the task has ten steps.
Success needs every step. 0.95 multiplied by itself ten times is about 0.6.
Which failure is this?
The agent says "Done!" but the file was never saved.
An agent can say it is done when it is not. Verify the result with code, not the model's words.
Where is the root cause?
The final answer is wrong, and the trace shows the error began at step 3 of 8.
Later mistakes follow from the first one. Fix the first step that went wrong.
Your reading position is saved
0 of 20 complete
Lesson complete
Why agents fail
Up next