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.


