Skip to main content

> Term

Token Loop

A cycle where an AI agent continuously generates tokens without reaching a stop condition, driving up costs.

Detailed Explanation

A token loop occurs when a generative AI agent enters a recursive cycle of self-prompting or tool execution without making progress toward a final goal. It rapidly consumes the context window and generates massive API charges.

Why It Matters

Unlike standard infinite loops that just burn CPU cycles, an LLM token loop burns actual dollars by continuously requesting expensive API completions until the budget or the context window collapses.

Common Failure Mode

Giving an agent self-correction capabilities without setting a strict iteration cap, allowing it to endlessly apologize for a mistake and try the exact same broken approach again.

Practical Example

Implementing a circuit breaker that hard-kills any agent thread after 5 consecutive tool calls that result in the same error state.

Production Manifestation

An autonomous agent repeatedly failing to parse a database schema, asking itself the same question, and re-querying the model until the API credits run out.

Frequently Asked Questions

What is Token Loop in short?

A cycle where an AI agent continuously generates tokens without reaching a stop condition, driving up costs.

What is the most common failure mode?

Giving an agent self-correction capabilities without setting a strict iteration cap, allowing it to endlessly apologize for a mistake and try the exact same broken approach again.

AI Summary

A cycle where an AI agent continuously generates tokens without reaching a stop condition, driving up costs. Unlike standard infinite loops that just burn CPU cycles, an LLM token loop burns actual dollars by continuously requesting expensive API completions until the budget or the context window collapses.