# Hard Limits: Steps, Time, Tokens, Money — Agent Loops, Stop Conditions and Token Budgets

Source: https://www.geekswithgeeks.com/en/agent-loops/stop-hard-limits

> Choose sensible default limits and decide what happens when each is reached.

## Four independent limits

Use several limits because each catches a different failure. **Steps** catch endless loops. **Wall-clock time** catches slow or hanging tools. **Tokens** catch context bloat. **Money** catches an expensive model used too often. Hitting any one should end the loop with a clear reason.

## Defaults in one place

Treat these numbers as a starting point to tune from real runs. A simple task needs far less than a research task.

```python
LIMITS = {
    "max_steps": 15,
    "max_seconds": 120,
    "max_total_tokens": 150_000,
    "max_cost_usd": 1.00,
}
```

## Decide the ending in advance

Per limit, decide: fail loudly, return a partial result, or ask a human. Deciding this at design time is much better than discovering it during an incident.

**Quiz:** Which limit best catches a tool call that hangs for minutes?

- [ ] Step limit
- [x] Wall-clock time limit
- [ ] Token limit
- [ ] Cost limit

*Answer:* Wall-clock time limit. A hanging call uses few steps and tokens but a lot of real time.
