Papa Programmer
Lesson 17 of 20

Why agents fail

7 min read

Optional

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.

python
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%
Chance that a task finishes when every step succeeds 95 times in 100

Five failure patterns

Most real failures fall into five groups.

  1. 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.
  2. 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.
  3. A loop. The agent repeats the same action and gets the same result. A step limit and a repeat detector stop it.
  4. 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.
  5. 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.

Errors compoundTen steps at 95% each succeed only about 60% of the time, so keep tasks short.
Five patternsWrong tool, false success, loops, lost context and bad sources cause most failures.
Find the first wrong stepRead the trace from the start, because later mistakes follow from the first one.

Your reading position is saved

0%

0 of 20 complete

Contents

Learning tools