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:
- Search Google for "competitor pricing"
- Analyze results
- Decide more info is needed
- Search Google for "competitor pricing"
- ... 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:
- Max Steps: Hard limit on total iterations (e.g., 10).
- Loop Detection: Detect if the agent calls the same tool with the same args repeatedly.
- Forced Termination: If limit reached, return what you have.
Requirements:
- Stop after
max_stepsiterations - 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