The Runaway Agent

Difficulty: HARDID: agent-loop-termination

The Scenario

You deployed an autonomous agent to "research competitors". You wake up to a $10,000 OpenAI bill.

The agent got stuck in a loop:

  1. Search Google for "competitor pricing"
  2. Analyze results
  3. Decide more info is needed
  4. Search Google for "competitor pricing"
  5. ... repeat 50,000 times

The Problem

Your agent loop uses while True with no safeguards. If the LLM doesn't decide to stop, it runs forever.

The Goal

Implement a Safety Harness for the agent loop:

  1. Max Steps: Hard limit on total iterations (e.g., 10).
  2. Loop Detection: Detect if the agent calls the same tool with the same args repeatedly.
  3. Forced Termination: If limit reached, return what you have.

Requirements:

  • Stop after max_steps iterations
  • Return the current state/result instead of crashing
solution.py
Loading...
⚠️ Do not include PII or secrets in your code.
SYSTEM_LOGS
5/5
// Waiting for execution trigger...
PREVIEW MODE — SOLVE PREVIOUS MISSIONS TO UNLOCK