Highreliability

Infinite Loop / Stuck Agent

Agent enters a repetitive cycle of actions without making progress toward the goal, consuming resources indefinitely.

Overview

How to Detect

Repeated identical or near-identical actions, increasing resource consumption, no task progress, circular reasoning in logs.

Root Causes

Missing termination conditions, inadequate error handling, poor state tracking, lack of progress metrics.

Test your agents against this failure mode
Try Playground

Deep Dive

Overview

Agents can get stuck in loops when they lack proper termination conditions, encounter edge cases in their reasoning, or when tools fail in ways the agent cannot handle.

Common Causes

Reasoning Loops

  • Agent keeps reconsidering the same options
  • Uncertainty leads to repeated analysis
  • Conflicting sub-goals create oscillation

Tool Interaction Loops

  • Tool returns same error repeatedly
  • Agent retries without adjusting approach
  • Missing error handling logic

State Management Issues

  • Agent doesn't track what it has tried
  • Memory limitations cause repeated attempts
  • Lack of progress detection

Prevention Strategies

  1. Set iteration limits - Hard caps on action counts
  2. Track action history - Detect repetitive patterns
  3. Implement circuit breakers - Automatic intervention triggers
  4. Progress monitoring - Require measurable advancement

How to Prevent

Add iteration limits and timeout mechanisms. Implement repetition detection. Create clear success/failure criteria. Add human escalation for stuck states.

Want expert guidance on implementation?
Get Consulting

Real-World Examples

Coding agents that repeatedly try the same fix for a failing test. Research agents that endlessly search without finding relevant results. Customer service bots that loop on clarification questions.