Problem
The loop detector currently warns at 10/20/30 identical tool calls but never force-stops the agent. Tonight a session called session_status 30+ times in a row. The detector printed warnings at every milestone but the agent kept going, creating a stuck session for 12+ minutes.
Current behavior
- Loop detected at N=10: prints warning in tool result
- Loop detected at N=20: prints stronger warning
- Loop detected at N=30: prints same warning
- Agent never stops — it ignores the warnings and keeps calling
Expected behavior
- N≤5 identical calls: warn
- N>5 identical calls: hard-abort the agent response (return error, force stop_reason, or kill the session)
- Configurable threshold (default 5, max 10)
Impact
- Stuck sessions block the queue (queueDepth=1 means other messages can't process)
- Burns API tokens on identical calls
- Required manual gateway restart to fix tonight (twice)
Logs
03:46:56+00:00 warn agents/loop-detection Loop warning: session_status called 20 times
03:46:56+00:00 warn agents/tools Loop warning for session_status: WARNING: You have called session_status 20 times with identical arguments. If this is not making progress, stop retrying and report the task as failed.
The agent received this warning in the tool result and still called session_status again.
Problem
The loop detector currently warns at 10/20/30 identical tool calls but never force-stops the agent. Tonight a session called
session_status30+ times in a row. The detector printed warnings at every milestone but the agent kept going, creating a stuck session for 12+ minutes.Current behavior
Expected behavior
Impact
Logs
The agent received this warning in the tool result and still called session_status again.