fix(tool-guardrails): detect content repetition across varying argument sets (#60084) - #60094
Closed
kyssta-exe wants to merge 1 commit into
Closed
Conversation
Collaborator
Duplicate of #60087 — both add a content-hash-only tool-result repetition tracker to |
This was referenced Jul 7, 2026
…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
kyssta-exe
force-pushed
the
fix/60084-tool-guardrails-content-loop
branch
from
July 7, 2026 19:33
8143934 to
d29bde5
Compare
Contributor
Author
|
Stale — 7-8 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.
Summary
Add a content-hash-only repetition tracker to
ToolCallGuardrailControllerthat catches loops where tool arguments vary but the result content stays the same.Problem
The tool-loop guardrails key their repetition tracking on the tool-call signature (tool name + canonical args) or on classified failure. Two loop shapes slip through both:
failedis false), and the_no_progresstracker is scoped to idempotent tools only.str(result)unique on every call even when the meaningful content is identical.Fix
A new
_same_content_countstracker keyed by result content hash only (no tool name, no args). Applied to ALL tools (not just idempotent ones) after the failure-clearing section inafter_call().New config knobs:
same_content_warn_after: 3 (default, viatool_loop_guardrails.warn_after.same_content)same_content_block_after: 6 (default, viatool_loop_guardrails.hard_stop_after.same_content)