DET-215 · agent · confidence High
Repeated Identical Tool Calls
Detect agent loops by counting repeated tool calls with the same arguments within one run.
A healthy agent rarely calls the same tool with the same input many times. Hashing the tool name and arguments per run, and alerting when the count passes a threshold or when tokens per minute climb steadily, catches runaway loops early, before the bill does.
Loops often start after a tool returns an error the agent cannot handle, so add the last error message to the alert. Injected content that keeps telling the agent the task is unfinished produces the same signature and is worth checking in the transcript. Kill the run automatically above a hard limit.
- Data sources
- Agent tool-call tracesLLM gateway usage logs
- Platforms
- AI Platform
Logic
SELECT run_id, tool, md5(args_json) AS h, COUNT(*) AS n, SUM(tokens) AS tok FROM tool_calls WHERE ts > now() - interval '1 hour' GROUP BY run_id, tool, h HAVING COUNT(*) >= 10 -- plus: runs with cost_usd > 5x the agent's p95, or duration > 2x max
False positives
Polling tools that are meant to be called repeatedly, such as waiting on a build.