loop: graduated guardrails — identical-call and consecutive-mistake detectors (closes #344)#352
Merged
Merged
Conversation
…etectors (closes #344) Two detectors watch every tool round, on by default with opt-out via RunRequest.Guardrails (zero value = defaults, mirroring RetryPolicy): - Identical-call: a single-call round whose name+canonicalized-args hash matches the previous round's extends a streak. At 3 the loop injects a corrective user message ("it will keep producing the same result — change arguments or approach"); at 5 the run ends with the typed ErrRepeatedToolCalls. Any change of arguments resets. - Consecutive mistakes: rounds where every tool result IsError. At 3 a corrective message ("re-read the error messages before acting"); at 6 the run ends with ErrTooManyMistakes. Any success resets. Injected messages are marked glue/guardrail in metadata; EventGuardrail reports kind/count/action so UIs and the goal loop can surface them. Graduated nudge-then-halt policy per Gemini CLI, with Cline's thresholds (docs/coding-harness-roadmap.md P2.8). The "no tool used" reprompt from the roadmap is deliberately omitted: glue turns legitimately end without tool calls, and the narrated-stall case is covered by AutoContinue (#343). TestRunMaxTurnsDefaultIs32 now disables guardrails — it scripts 50 identical calls to test the turn budget, which the repeat detector would correctly halt first. Co-Authored-By: Claude Fable 5 <[email protected]>
glue-reviewNo concerns — LGTM. New guardrails for repeated tool calls and consecutive mistakes are well-implemented with appropriate graduated nudges and halt limits, backed by a comprehensive test suite. 🤖 Posted by glue-review. |
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.
Closes #344. Roadmap P2.8.
Two graduated detectors (
RunRequest.Guardrails, on by default,Disabledopt-out — same shape asRetryPolicy):ErrRepeatedToolCalls(typed) at 5ErrTooManyMistakes(typed) at 6glue/guardrailin metadata;EventGuardrailcarries kind/count/action (nudge|halt) for UIs and the goal loop.Tests: nudge-then-halt for both detectors (call counts, event actions, typed errors), reset-on-different-args, reset-on-success, disabled passthrough, nudge message shape. One existing test (default-max-turns) now disables guardrails since its scripted 50 identical calls are exactly what the detector halts. Full suite + vet green.
🤖 Generated with Claude Code