feat(agents): escalate unbroken identical tool-call runs (consecutive-repeat detector)#112447
Open
interkelstar wants to merge 1 commit into
Open
feat(agents): escalate unbroken identical tool-call runs (consecutive-repeat detector)#112447interkelstar wants to merge 1 commit into
interkelstar wants to merge 1 commit into
Conversation
…-repeat detector) The generic loop detector's critical tier requires identical results (noProgressStreak): a model stuck re-issuing the same call whose output differs every time (timestamps, fresh page dumps, rate-limited errors with new request ids) only ever produces a log-side warning the model never sees, and runs until the token budget burns out. Add a consecutive-repeat detector: an unbroken run of byte-identical (tool, args) calls — nothing else interleaved — escalates to a critical veto at criticalThreshold regardless of result hashes. The veto reason reaches the model as the tool result, which both breaks the streak and tells the model how to proceed. Known polling tools and messaging sends are exempt (polling legitimately repeats; sends have their own volatility-strip escalation that understands result-side progress, openclaw#89090). Deliberate behavior change: two exec tests that pinned changing-output runs at warning level now expect the consecutive critical instead; their original concern (the global no-progress breaker must not fire on changing results) still holds and is asserted via the detector kind. Closes openclaw#78865 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WN55iikjZy6hKzFuzL6Gey
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(agents): escalate unbroken identical tool-call runs (consecutive-repeat detector) This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
#78865 asks for a platform-level circuit breaker: "If the same tool is called with similar arguments N times… block the next call", because "AGENTS.md is a suggestion… the enforcement has to happen at the platform level, not the prompt level."
Today the generic detector's critical tier requires identical results (
noProgressStreakresets whenever the result hash changes). A model stuck re-issuing the same call whose output differs every time — timestamps, fresh page dumps, rate-limited errors with new request ids — only ever produces a log-side warning the model never sees, and runs until the token budget burns out.Production incident that motivated this (OpenClaw 2026.7.1, mimo-v2.5): a model re-issued the identical
exec date +%Scall 62 times in an unbroken run — every result differed (seconds changed), so nothing escalated past the log warning; the turn ended only by output-token exhaustion (stopReason=length, ~34K output tokens). A second incident the same week ran a browser-workflow marathon of 141 rounds for the same reason.Why This Change Was Made
Adds a
consecutive_repeatdetector: an unbroken run of byte-identical (tool, args) calls — nothing else interleaved — escalates to a critical veto atcriticalThreshold, regardless of result hashes. The veto reason reaches the model as the tool result, which both breaks the streak and tells the model how to proceed.Scope guards:
Deliberate behavior change: two exec tests that pinned changing-output runs at warning level now expect the consecutive critical instead. Their original concern — the global no-progress breaker must not fire on changing results — still holds and is still asserted (via the detector kind). If you'd prefer a separate, higher threshold for this tier instead of reusing
criticalThreshold, happy to adjust.User Impact
Runaway identical-call loops stop after
criticalThresholdconsecutive calls with an actionable, model-visible message, instead of silently burning the run budget. No config surface changes (the detector rides the existing internal defaults; disabled together withtools.loopDetection.enabled=false).Evidence
pnpm test -- src/agents/tool-loop-detection.test.ts— 56/56 pass (3 new tests: unbroken-run block with varying results; interrupted run does not escalate; below-threshold stays at warning).pnpm run tsgo:prod— clean.Closes #78865