# Unbounded Loop

> Running the agent loop with no step budget — and trusting model self-termination to decide when to stop.

- **Category**: Agentic AI
- **Subcategory**: Anti-Patterns
- **Canonical URL**: https://designpattern.fyi/patterns/unbounded_loop/

---

## Description
**Intent**: Iterating while the model reports it''s not done, with no external counter, timer, or cost cap.

**Context**: The loop is "keep going until the model says DONE." No max_steps. No timer. No cost gate. The model oscillates, drifts, or simply forgets to terminate. The bill arrives before the task does.

**Solution**: Set max_steps. Add a stop hook. Pair with cost-gating to cap total spend per task. See step-budget, the-stop-hook.



## Use Cases
- Never use this; agent termination depends on the model''s own output — which is unreliable.
- Set max_steps and add a stop hook (see step-budget, the-stop-hook).
- Pair with cost-gating to cap total spend per task.






## Trade-offs




### Considerations & Drawbacks

- Cost blows up when the model loops, oscillates, or drifts without terminating

- Silent quality regressions when the model wanders past the useful work







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/unbounded-loop/)

