fix(tool-guardrails): detect content-repetition loops across varying args (#60084) - #60219
Closed
kyssta-exe wants to merge 1 commit into
Closed
kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
…args (NousResearch#60084) The tool-loop guardrails miss two loop shapes: 1. Varying-args / fixed-result loops where tool arguments change but the return value is always the same (e.g. fetching a blocking error page) 2. Repeated multimodal results where base64 image payloads make every result string unique even when the meaningful content is identical This fix adds: - _semantic_result_hash(): hashes result content after stripping base64 multimodal payloads, so vision-tool image reloads are detected - _strip_multimodal_content(): recursively replaces large base64 strings and _multimodal=True content blocks with placeholder markers - _content_repetition tracker in ToolCallGuardrailController: maps (tool_name, semantic_hash) -> repeat_count, catching same-content results regardless of argument variation - Tracking fires for ALL tools (not just idempotent ones), emitting a 'repeated_content_warning' after the configured threshold Fixes NousResearch#60084
Duplicate of #60087 — same content-hash-only result-repetition axis for #60084 in |
This was referenced Jul 7, 2026
Contributor
Author
|
Stale — 6-7 days without merge activity. Can resubmit if still needed. |
1 task
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.
Problem
The tool-loop guardrails in
agent/tool_guardrails.pymiss two loop shapes:_no_progresstracker is keyed byToolCallSignature(tool name + args hash), so varying args resets the counter.str(result)unique even when the meaningful content is identical.Fix
_semantic_result_hash()that strips base64 multimodal payloads before hashing, so vision-tool image reloads are detected_strip_multimodal_content()that recursively replaces large base64 strings and_multimodal=Truecontent blocks with placeholder markers_content_repetitiontracker inToolCallGuardrailControllerthat maps(tool_name, semantic_hash) -> repeat_count, catching same-content results regardless of argument variationrepeated_content_warningafter the configured thresholdFixes #60084