AI Agents and Coding Assistants

Why Errors Compound When an AI Takes Many Steps in a Row

See the simple arithmetic behind long-task failures in AI agents, why real runs differ from the math, and which habits keep mistakes from piling up.

Key takeaways

  • Success rates for steps in a chain multiply, so high reliability per step can still mean frequent failure overall.
  • An early mistake can be worse than the arithmetic suggests, because later steps treat it as fact.
  • Checks that detect errors and allow retries can raise overall success a great deal.
  • Shorter tasks, outside evidence and checkpoints are the most practical ways to limit compounding.

When a task requires many steps and each one must be right, the chance of getting through them all falls as the chain grows longer. A step that succeeds 95 times in 100 sounds dependable. Twenty such steps in a row, if their failures are independent and nothing repairs them, all succeed only about 36 times in 100.

This is the central difficulty with long automated tasks. The rest of this article shows the arithmetic, explains why real agents can do better or worse than it predicts, and describes what helps.

The arithmetic

Suppose each step succeeds with probability p, independently of the others, and a task needs n steps that must all be correct. The chance the whole task succeeds is p multiplied by itself n times.

P(task succeeds) = pⁿ

p = 0.95, n = 5    0.95⁵  ≈ 0.77
p = 0.95, n = 10   0.95¹⁰ ≈ 0.60
p = 0.95, n = 20   0.95²⁰ ≈ 0.36
p = 0.99, n = 20   0.99²⁰ ≈ 0.82
p = 0.99, n = 100  0.99¹⁰⁰ ≈ 0.37

Two lessons stand out. Length is punishing: the same per-step quality that looks fine over five steps looks poor over twenty. And small gains in per-step reliability matter a great deal. Moving from 95 to 99 percent turns a twenty-step task from usually failing into usually succeeding.

These figures are illustrations. Nobody can tell you the true value of p for your task without testing, and it differs from step to step.

Example: chance all steps succeed at 95% per step
1 step 95% 5 steps 77% 10 steps 60% 20 steps 36% 40 steps 13% 1 step 95% 5 steps 77% 10 steps 60% 20 steps 36% 40 steps 13%

Hypothetical example: the numbers are made up to show the method, not a quote or an average.

Why an early mistake spreads

The simple formula treats each step as a separate coin toss. Real agent tasks are more tangled. Step six reads what step five produced and usually believes it.

Say you ask an agent to total last quarter's sales from a set of files, and in the second step it picks an outdated version of one file. Every later calculation can be flawless and the answer will still be wrong. Worse, the final report may be tidy and internally consistent, which makes the problem harder to notice.

Language models also tend to continue in the direction already established. If the history contains a mistaken assumption, such as "the customer is in the northern region", later steps may build explanations that fit it. When a contradiction does appear, the agent might explain it away rather than revisit the assumption.

This is why an invented detail is more costly inside an agent than in a single chat reply. In a chat you can read it. Inside a chain, it becomes an input.

Why real agents sometimes beat the math

The formula assumes that one failed step sinks the task. That is not true when errors can be seen and fixed.

Suppose a step fails 10 percent of the time, a check catches every failure, and one retry is allowed with the same independent odds. The step now fails only if both attempts fail.

single attempt:     fails 0.10 of the time
with one retry:     0.10 × 0.10 = 0.01
success per step:   from 0.90 to 0.99
over 10 steps:      0.90¹⁰ ≈ 0.35   becomes   0.99¹⁰ ≈ 0.90

That is a large improvement, and it explains why agents often do well where there is clear feedback, such as running code against tests. The assumptions are generous, though. Real checks miss some errors, and a second attempt is often not independent of the first. If the model misunderstood the request, retrying will likely repeat the misunderstanding.

Why real agents sometimes do worse

Several things can make long runs less reliable than independent coin tosses would suggest.

  • Growing history. As a task lengthens, early instructions compete with a mass of later material, and details may be summarized or dropped when the context window fills.
  • Drift. The agent gradually works toward a slightly different goal, such as making a test pass instead of fixing the underlying fault.
  • Side effects. A failed action may leave things half changed, so the next attempt starts from a worse place.
  • Outside changes. A web page loads differently, a login expires or someone edits a file during the run.
  • False success. A tool reports no error even though nothing useful happened.

Planning far ahead adds its own difficulty, as discussed in how well AI can plan several steps ahead.

Not every error costs the same

The formula counts a task as passed or failed. Real work has shades. A misspelled file name that raises an immediate error costs a few seconds. A wrong exchange rate that flows silently into a report may cost far more than the whole task was worth.

It helps to sort possible errors into three kinds:

Kind of error Example Effect on a long run
Loud A command fails with a message Usually noticed and retried
Quiet A search returns the wrong year's document Carried forward unnoticed
Permanent A record is overwritten with no backup Cannot be repaired by later steps

Loud errors are the friendly ones. Much good agent design consists of turning quiet errors into loud ones, for instance by requiring that a total match a known figure before work continues. Permanent errors call for prevention: backups, copies and approval before the action.

When you review a task, ask which kind each step can produce. A step that fails often but loudly may worry you less than one that fails rarely and quietly. The same ranking tells you where your own reading time is best spent.

Habits that limit the damage

You can attack the problem from both sides of the formula: fewer unchecked steps, and better odds on each one.

  1. Cut the chain. Break a large job into stages, and verify each stage before starting the next.
  2. Check with evidence. Prefer tests, totals, counts and confirmation numbers to the agent's own opinion.
  3. Put checks early. Confirm the right files, the right account and the right interpretation before building on them.
  4. Make actions reversible. Work on copies, keep versions and delay permanent steps to the end.
  5. Use ordinary code for fixed steps. A formula that adds a column does not need a model's judgment.
  6. Ask for open questions. Tell the agent to list its assumptions and what it could not confirm.

A checkpoint is a deliberate stop where a person or an automatic test must pass the work before it goes on. Two or three well-chosen ones often do more than watching every step.

Estimating the risk for your own task

You do not need precise numbers to use this idea. Write out the steps your task really involves. Mark which can be checked automatically, which only a person can judge and which cannot be undone.

Then run the whole task several times on safe test data and count complete successes, since partial successes can flatter a tool. If three of ten runs go wrong somewhere, find the step where they diverged. Often one or two weak steps account for most failures, and improving those changes the result more than polishing the rest.

Compare the outcome with the cost of checking. An agent saves time only after review is counted, and a long chain that needs line-by-line inspection may save none.

Where to place a checkpoint

A checkpoint helps most when it sits just before a lot of work depends on a decision, or just before something cannot be reversed. Imagine a hypothetical task: compile a contact list, write a tailored note to each person and send the notes.

A check after the list is compiled catches wrong or duplicated names before any writing happens. A check on three sample notes catches a bad tone or a wrong assumption before it is repeated two hundred times. A final approval before sending protects the one step that cannot be taken back.

Watching every keystroke between those points would add effort and little safety. By contrast, a single review at the very end, after sending, adds none.

The arithmetic shows why this works. A checkpoint that catches errors resets the chain. Instead of needing twenty consecutive successes, you need several short stretches, each of which can be redone on its own if it fails. Redoing four steps is also far cheaper than redoing twenty, so the same error rate costs you much less time.

A common misconception

People sometimes assume that an agent which handles a short demonstration well will handle a longer job in proportion. The arithmetic above shows why this does not follow. A demonstration of five steps is a different test from a project of fifty.

The reverse mistake is to conclude that long tasks are hopeless. Reliability on extended work has been improving, and designs with good feedback and recovery can complete long jobs. Check results for the particular tool and task, and expect the answer to change over time. The durable point is that length multiplies risk unless something along the way catches and repairs errors.

Written for 4ArtificialIntelligence with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 46 articles in AI Agents and Coding Assistants →

Latest news on this topic