What to do when an agent goes in circles
If an agent keeps trying fixes that don't work, more of the same rarely helps. Stop it, get a diagnosis, and restart with what you learned, a plan, or a different agent.
Signs you’re in a loop: the same error keeps coming back, the agent says it’s fixed when it isn’t, or each fix undoes an earlier one. Claude Code’s guide explains why pushing on rarely works: after repeated corrections, “the context is cluttered with failed approaches.”
What to do
- Stop the work. Select Stop next to the status under the conversation’s title. The status changes to Stopped. Changes the agent already made stay in your project. Retry runs the interrupted request again if you change your mind.
- Ask for a diagnosis, not another fix. “Don’t change anything yet. Explain what you think is causing this, what you’ve tried so far, and what you’d check next.” A wrong explanation is easier to spot than a wrong fix.
- Give better evidence. Attach a screenshot, paste the exact error text, and list the steps that make it happen. Ask the agent to reproduce the problem before fixing it, so it can tell when it’s really solved.
- Start fresh with what you learned. Claude Code’s guide is direct: “If you’ve corrected Claude more than twice on the same issue in one session,” start over, because “a clean session with a better prompt almost always outperforms a long session with accumulated corrections.” Start a new conversation, describe the problem from scratch, and say what didn’t work. See Start fresh when a conversation gets long.
- Plan the next attempt. For tangled problems, ask for a plan first. See Plan before you build.
Try a different agent or more effort
- Switch agents in the same conversation. Open the agent settings from the button in the message box that shows your agent’s name, choose another agent, and send your message. Enjoy gives the new agent the conversation so far, so it starts with what was tried. Each agent keeps its own session and settings, so switching back later resumes where the first one left off.
- Raise the effort for this problem. Claude Code’s documentation suggests High for “work where verification matters or edge cases are likely, such as fixing a bug in an existing codebase.” See Match the effort level to the task.
- Retry with new settings. After a failure or a stop, change the agent, model, or effort, and a Retry with button appears beside Retry.
You can switch agents from the computer app or the web app. In the web app, an agent that would need broader permissions than the conversation has is unavailable, so choose it on your computer.
An example
The agent has “fixed” the login page three times, and it still logs people out. You select Stop, then send:
“Let’s step back. Don’t change any code. List the reasons people could be logged out, what you’ve tried for each, and how we could prove which one it is.”
The answer shows it never checked how long sign-ins last. You start a new conversation: “People get logged out after a few minutes. It isn’t the cookie settings or the login form; we checked those. Find out how long sign-ins last and why, prove it with a test, then fix it.”
Common pitfalls
- Letting it run. A loop uses your plan without making progress. Stop early.
- “Still broken.” Say what you saw this time, and how it differs from before.
- Forgetting the mess. Failed attempts can leave half-finished changes. Ask the agent to undo them, or go back to your last commit. See Try ideas without risking your project.