Agents

What to do when an agent keeps getting the same step wrong

Editorial · Reveneau · December 8, 2026

What to do when an agent keeps getting the same step wrong

An agent that fails the same step three times in a row is not going to pass it on the fourth. Retries help with genuinely transient failures: a network blip, an API that was briefly unavailable, a rate limit that resets in a minute. Retries do not help when the failure is caused by how the step is set up. In that case, every attempt hits the same underlying problem and produces the same failure.

The specific cause is almost always one of four patterns. Each has a different signature, which means a reviewer who knows the patterns can diagnose the right one from the agent's output. Each has a different fix, and none of the fixes is "try more times".

Pattern one: the instruction is ambiguous

The agent is asked to do something, and the instruction leaves room for two or more reasonable interpretations. One of the interpretations leads to failure. The agent, with no specific reason to pick one, picks the wrong one more often than it picks the right one, and the step fails.

The signature of this pattern is that the agent produced something that looks reasonable but is not what the team wanted. The agent did the work, the output is structured, the tests pass on the agent's version, and the result still does not meet the requirement. The problem is in the mapping between the instruction and the outcome, not in the agent's execution.

The fix is to rewrite the instruction so that the right interpretation is the only reasonable one. "Update the user profile" becomes "Update the user profile by calling profileService.update(userId, { field: value }), which should update the specific field passed and leave the others unchanged". The new instruction names the method, the inputs, and the expected effect. An agent reading it produces the specific action the team meant.

Rewriting for specificity is almost always the fix for this pattern, and it is a change to the setup, not to the agent. Teams that spend time tuning the agent's prompt generally and do not tighten the task-level instruction are working on the wrong layer.

Pattern two: the context is missing

The agent needs information to complete the step, and the information is not in the context the agent has. The task says "update the record for this user", and the task does not include the user ID. The agent has to infer the ID from some other field, or guess, or give up.

The signature of this pattern is that the agent either asks for information it does not have, produces a result that is clearly a guess, or declines to proceed and reports the missing piece. In a well-behaved agent this looks like a specific error message or a question in the output. In a less well-behaved one it looks like the agent making up a value and running with it, which produces a worse failure downstream.

The fix is to supply the information in the task. If the task needs the user ID, include the user ID. If the task needs a reference to a document, include the reference. If the task needs the shape of an external API, include the shape. Expecting the agent to find the information is a strategy that works only when the information is straightforwardly findable; for anything less obvious, the context has to be provided.

The related anti-pattern is to give the agent a tool that could find the information (a web search, a code search, a database query) and expect it to use the tool. This sometimes works, but it is slower, costs more, and introduces another failure mode (the tool returning the wrong result, which the agent then acts on). Where the information can be in the task, put it in the task.

Pattern three: the task is structured in a way the agent cannot complete in one step

The task describes work that requires several sequential actions, each dependent on the previous. The agent is expected to produce all of them at once. Agents are usually poor at this, because the output of the first action feeds into the inputs of the second, and the agent has to hold the intermediate state while producing all of the actions.

The signature is partial completion. The agent gets the first action right and the second wrong. Or the first two right and the third wrong. Or in some orders, depending on the specific task. The failures are not consistent, because the agent is improvising its way through a multi-step task without the structure to help.

The fix is to decompose the task into separate steps with explicit intermediate state. Step one produces an output. Step two takes that output as input and produces the next. Step three takes that output and produces the final result. Each step has its own success check and its own retry logic. The agent is no longer trying to hold three things in mind at once; it is doing one thing per step, with the previous step's output in the context.

This is one of the most common causes of agent failure on non-trivial tasks, and the fix is almost always a change to the orchestration layer rather than the agent. For related reading, see how to tell a system one task from a system two task and when an agent should ask for help instead of proceeding.

Pattern four: the tool permissions do not allow the action

The agent is trying to take the right action, and the tool it is using to take that action is refusing. The permission to write to the file was not granted, the API key does not cover the endpoint, the sandbox does not allow the network call. The agent is doing the right thing, but it cannot execute.

The signature is a specific error message, usually from the tool, that indicates permission denial. The agent then either retries (and gets the same error), works around (and produces something lesser), or gives up and reports the error.

The fix is to audit the tool permissions the agent has before the task runs, and grant the permissions the task requires. This is straightforward in principle. In practice, teams often default to minimal permissions for safety reasons and discover gaps on specific tasks. The permissions should be the ones the task needs, no more and no less.

A related anti-pattern is to grant broad permissions to make the issue go away. A sandbox that allows everything prevents the permission errors and also prevents the sandbox from doing its job. The useful adjustment is specific: for this task, grant the specific action; for others, keep the sandbox narrow. For related reading, see how to audit an ai agents tool permissions and why permissions are the hardest part of an ai feature.

How to tell which pattern applies

The four patterns have different signatures, and matching the agent's output to the signature is the fastest way to diagnose.

Reasonable-but-wrong output: ambiguous instruction. The agent did the work, the work is not what was asked for.

Agent asking or guessing: missing context. The agent flagged the gap, or filled it badly.

Partial completion with no pattern: structural mismatch. The agent is doing some of the task and failing on others in no reliable order.

Error from a tool: permission mismatch. The agent tried, the tool refused.

A combination can happen: ambiguous instruction plus missing context, for example, or structural mismatch plus one of the others. The diagnosis then names both, and both fixes are applied. The common case is one dominant cause, and identifying it is a 10-minute exercise once the patterns are familiar.

When to stop retrying and step in

Retries are useful for transient failures. They are not useful for the four patterns above. The signal that retries have stopped helping is simple: if the agent failed the same step twice with the same error on the same inputs, the third attempt is unlikely to produce a different outcome.

At that point the team's time is better spent on diagnosis than on more attempts. A 10-minute diagnosis followed by a 20-minute fix typically beats an hour of retries that all fail the same way, both on cost and on reliability.

Sometimes the diagnosis reveals that the fix is expensive. The missing context would take a day to gather. The structural decomposition requires a change to the system that is outside the current project's scope. In those cases, the team is often best served by stepping in and doing the step themselves, once, while the structural fix is scheduled for later. The agent is a tool, and stepping in when the setup cannot be fixed is the correct response, not a failure of the agent.

For related reading, see how to write a design doc an agent can implement from and how to handle a model upgrade without breaking your evals.

Preventing the pattern on the next task

The four patterns are preventable. A team that notices they are hitting them often can change their practice to reduce how often they appear.

Write task instructions that are specific enough that a reasonable interpretation produces the right output. Err on the side of specifying more than you think the agent needs. The cost of over-specifying is a longer task description; the cost of under-specifying is a round of failures and fixes.

Provide context in the task rather than expecting the agent to find it. If the agent needs an ID, include the ID. If the agent needs a shape, include the shape. Tools for context-fetching are a fallback for cases where the context cannot be in the task; they are not the default.

Decompose tasks that have multiple dependent steps. A task with three sequential actions is three tasks, not one. The decomposition costs a little upfront and saves a lot of debugging time later.

Audit tool permissions before the agent starts. List the actions the task needs and confirm the agent has permission for each. Grant what is needed; keep the rest narrow.

Teams that follow these four practices rarely see repeated-step failures. Teams that do not, see them often and spend time on retries that do not pay off.

Common questions

Why does an agent keep failing the same step?

Because something in how the step is set up makes a correct outcome unlikely, and the agent will keep hitting that something on every attempt. The specific cause is usually one of four: the instruction is ambiguous, the context is missing, the task is structured in a way the agent cannot complete in one step, or the tool permissions do not allow the action the agent needs to take. Retrying without changing any of these does not help.

How many retries are reasonable before stopping?

Two. If the agent failed the same step twice with no changes to the setup, a third attempt is unlikely to produce a different outcome, and the time is better spent diagnosing the cause. Teams that retry five or ten times are running up cost without gaining information. The pattern is similar to a failing unit test: a flaky test that fails three times in a row is not a flake, it is a broken test.

What is an ambiguous instruction?

One that leaves room for the agent to pick between two reasonable interpretations, where one of the interpretations leads to failure. "Update the user profile" is ambiguous when the system has three ways to update profiles and the agent might pick the wrong one. A specific instruction names the method, the inputs, and the expected result. Rewriting the instruction to remove the ambiguity usually fixes the step without any change to the agent itself.

What is missing context?

Information the agent needs to complete the step that the agent does not have access to. The agent is asked to update a record, but the record ID is not in the task; the agent has to infer it from some other field that is ambiguous. The agent is asked to generate code that integrates with a library, but the library's documentation is not in the context. Supplying the missing context is a direct fix: if the agent has the information, it can usually complete the step.

What is a structural task mismatch?

A task that is too big to do in one agent step but is being presented as one. The task requires three sequential actions, each dependent on the previous, and the agent is expected to produce all three at once. The agent gets the first right and the others wrong, or vice versa. The fix is to break the task into three separate steps, each with its own success check.

How do you tell which of the four causes applies?

Look at what the agent produced and what it was supposed to produce. If the agent did something reasonable but wrong, the instruction was ambiguous. If the agent could not find information it needed, the context was missing. If the agent did part of the task correctly and part not, the task was too large. If the agent tried to take an action and got an error, the tool permissions were wrong. The four causes have different signatures, which is what makes them distinguishable.

When should the team step in and do the step themselves?

When diagnosis has identified a cause that is not fixable in a reasonable time. If the missing context would take a day to gather, a human doing the step takes less time. If the task structure requires an architectural change to the system to make it decomposable, the human doing one instance is cheaper than the change. The agent is a tool, not a principle, and stepping in when the setup cannot be fixed is the correct response.

What does a good diagnosis look like?

A specific statement of which of the four causes applies, with evidence from the agent's output. "The agent is failing step 3 because it is being asked to both parse the file and send the notification in one step, and it is getting one right at the expense of the other. The fix is to split this into two steps with an intermediate state." The diagnosis names the cause and the fix.

What is the role of retries at all?

Retries are useful for genuinely transient failures: a network error, a rate limit, an API that was briefly unavailable. They are not useful for repeated failures on the same step, where the failure is caused by the setup. Distinguishing transient failures from setup failures is the first thing a retry policy should do. If the failure is the same error with the same inputs on the second try, it is a setup failure, not a transient one.

How do you prevent this from happening on the next project?

Write task instructions that are specific enough that a reasonable interpretation produces the right output. Provide context in the task rather than expecting the agent to find it. Decompose tasks that have multiple dependent steps. Audit tool permissions before the agent starts. These four practices prevent most of the repeated-failure cases.

Start a project