---
title: "If your agent is stuck in a loop, send in a second one"
description: "Is your agent trying to fix the same thing for the tenth time? Open a new session, point them to the stuck session and ask for the root cause."
language: en
source: https://coachsteff.live/en/als-je-agent-in-een-lus-zit
---

# If your agent is stuck in a loop, send in a second one

Your agent has been working on one little problem for twenty minutes. It tries something, it does not work. It says it understands now and tries something else. It fails again. And then it starts over with the first solution. You sit there watching it and you actually already know it is not going to work. Yet with every attempt you hope a little bit that it will work this time.

In the training on building with AI, I called that a dead loop. With the new models, I have encountered it much less since the summer. But it still happens, for example when an agent has to test something in a browser and gets stuck somewhere. It then tries to fix it internally, and that just does not work.

At the bottom of this article you will find the prompt I use then. Feel free to copy it.

## Why the agent cannot get out of it itself

An agent stuck in a loop looks at its problem from within its own conversation. And that conversation is meanwhile full of failed attempts, error messages and half solutions. The longer it takes, the more of that rubbish it drags along. You can ask it to think for a moment, but it thinks with the same context that brought it into the loop. It is a bit like asking someone who is lost to find the way on their own, wrong map.

## Open a new session and point to the old one

What I do then is open a new session. In Claude Code and in Craft Agents you can copy the ID or the path of a session. I give that to the agent in the new session. And I say: something is going wrong in that session, we are in a loop there. Have a look at what is happening and make sure we get out of it.

## Frequently asked questions

**What is a dead loop with an AI agent?**

- The agent keeps trying to solve the same problem over and over and cannot get out of it. It repeats attempts that already failed, because its conversation is full of those failed attempts.

**Why does a new session help?**

- A new agent looks at what happened with a fresh perspective, without being stuck in it itself. Because of this, it can look for the cause instead of making another attempt.

**What is the problem with a quick fix?**

- A quick fix solves what you see in one place. If the cause is deeper, the problem will pop up again elsewhere. Therefore, ask to tackle it thoroughly.

**Where do I learn to build with agents like this?**

- In the Vibe Coding with AI and AI agents training courses, you work with real agents on your own project. You can find the dates at [Workshops & Events](https://coachsteff.live/agenda).
