Skip to content
All challenges
AgentsAdvanced

The agent that wouldn't stop

Your research agent occasionally runs for 40+ minutes and costs $15 per run before timing out. The agent keeps calling the same tool with slightly different arguments. Diagnose and fix.

How to investigate an agent run that will not end
1 / 5Read the trace

Step 1 of 5

Read the trace

Start with the step-by-step trace of a slow run, not the averages. List each action and its arguments in order.

Compare each step with the one before it, then ask what in the setup could have ended the run.

Symptoms
  • Mean run: 90 seconds. P99 run: 40+ minutes.
  • Cost spikes — some runs cost $15+
  • Agent calls search() 20+ times with paraphrased queries
  • Final answer is still wrong
Evidence

Agent trace (excerpt)

Step 1: search('latest RAG techniques')
Step 2: search('new RAG methods 2025')
Step 3: search('retrieval augmented generation advances')
Step 4: search('RAG research papers recent')
...
Step 24: search('RAG innovation 2025 Q1')
Step 25: final answer (timeout)

System prompt

You are a research agent. Be thorough. Do not stop until you have comprehensive information.

Tool config

max_iterations: not set
timeout: 45min (global)
cost_budget: not set
Tasks
  • 1Identify why the agent loops
  • 2Design guardrails to prevent it
  • 3Improve the prompt to avoid the behaviour