Tool-loop detection
WednesdayAI can keep agents from getting stuck in repeated tool-call patterns. Most of the guard is disabled by default; enable it only where needed, because strict settings can block legitimate repeated calls. One detector,sameErrorRepeat, is on by default, as upstream OpenClaw’s repeat guard is. It blocks a tool that keeps failing with the same error even when its arguments change. To turn it off, set detectors.sameErrorRepeat: false, or set enabled: false to turn off every detector.
Why this exists
- Detect repetitive sequences that do not make progress.
- Detect high-frequency no-result loops (same tool, same inputs, repeated errors).
- Detect specific repeated-call patterns for known polling tools.
Configuration block
Global defaults:Field behavior
enabled: Master switch forgenericRepeat,knownPollNoProgress,pingPongand the global circuit breaker (default: false). When unset, onlysameErrorRepeatruns. An explicitfalseturns every detector off.historySize: number of recent tool calls kept for analysis (default: 30).warningThreshold: warning threshold before a warning-only loop classification (default: 10). Must be lower thancriticalThreshold.criticalThreshold: critical threshold for blocking repetitive loops (default: 20). Must be lower thanglobalCircuitBreakerThreshold.globalCircuitBreakerThreshold: global no-progress breaker threshold (default: 30).detectors.genericRepeat: warns when the same tool is called with the same argumentswarningThresholdtimes.detectors.knownPollNoProgress: warns, then blocks, known polling tools whose output stops changing.detectors.pingPong: warns, then blocks, alternatingA/B/A/Bcalls that make no progress.detectors.sameErrorRepeat: warns atwarningThresholdand blocks atcriticalThresholdwhen one tool fails with the same error that many times in the current run, even if its arguments change. Only failures still within the lasthistorySizetool calls count, so the block lifts once other tool calls push them out of that window. A success of that tool resets the count, and a new run starts from zero.
Recommended setup
- Start with
enabled: true, defaults unchanged. - If false positives occur:
- raise
warningThresholdand/orcriticalThreshold - disable only the detector causing issues
- reduce
historySizefor less strict historical context
- raise
Logs and expected behavior
When a loop is detected, WednesdayAI reports a loop event and blocks or dampens the next tool-cycle depending on severity. This protects users from runaway token spend and lockups while preserving normal tool access.- Prefer warning and temporary suppression first.
- Escalate only when repeated evidence accumulates.
Notes
tools.loopDetectionis merged with agent-level overrides.- Per-agent config fully overrides or extends global values.
- If no config exists, only
sameErrorRepeatruns.