Code prompts
Code prompt

Escape an AI agent loop

Your agent has tried 3+ times and the test still fails. Diagnose what's actually wrong and produce a fresh-session restart prompt.

Works best in: Claude

My AI coding agent is stuck in a loop. Help me diagnose and restart cleanly.

The original task:
{{what you asked the agent to do}}

The actual failure (paste the error, not your summary):
```
{{paste exact error / test output}}
```

Attempts the agent has made:
1. {{what it tried}}
2. {{what it tried}}
3. {{what it tried}}

Relevant code the agent has been editing:
```
{{paste files}}
```

Diagnose:

1. **Which loop mode is this?**
   - Wrong target — agent is fixing the wrong line; cause is in a config / env / different module
   - Missing context — right line, wrong information about it (invented APIs, wrong types)
   - Conflicting instructions — earlier conversation context is poisoning the reasoning
   - Wrong tool — model can't actually do this in this environment

2. **Evidence** — quote the specific transcript signal that points to that mode.

3. **What's missing** — the concrete piece (file, schema, version, signature) the agent doesn't have.

4. **Restart prompt** — write me a self-contained prompt I can paste into a fresh session. Include the missing context inline. Don't reference the previous conversation.

5. **Stop signal** — if the restart also fails, what's the cue to stop using AI for this and write it myself?
·Open in·Share

Tip: Restart in a fresh conversation, ideally a different model. The accumulated context is usually the problem.

ai-loopagentdebugging

More code prompts

All code prompts

Go deeper