# How to Stop an AI Agent Infinite Loop

> Source: <https://dev.to/interro-ai/how-to-stop-an-ai-agent-infinite-loop-1ajd>
> Published: 2026-09-26 16:24:07+00:00

A simple planning request triggered 105 calls to the same goal tool. The system did not crash immediately. It kept spending tokens until the turn limit stopped it, without producing a useful answer.

This was INC-001: goal tools were exposed globally instead of being scoped to the node that owned goal state. Every model node could ask for the same incomplete goal, so the graph kept returning to the same decision.

A configuration value is not a guard unless the live loop reads and enforces it. The regression test should assert that a 4+4 request terminates and that planning nodes cannot call goal-state tools.

PreventAI can flag source patterns associated with this incident:

```
prevention-scanner scan . --format json
```

The scanner is heuristic. Pair it with graph, load, and termination tests.

Read the [full INC-001 incident](https://github.com/InterroAI/interro-awesome-agent-incidents/blob/main/INC-001-goal-loop.md), then audit which node owns every tool in your agent.
