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.
Step 2 of 5
Diff the steps
Compare each step with the previous one. Did it learn something new, or ask for essentially the same thing again?
Step 3 of 5
Find the exits
List everything that could stop a run: limits in the config, budgets, and what the prompt says counts as finished. Note which ones exist.
Step 4 of 5
Read the prompt
Read the instructions as the model would. Is there a condition it can actually check to know it is done?
Step 5 of 5
Test one change
Change a single thing, replay the slow case and check the trace again. If it still loops, you learned which suspect to drop.
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