Skip to content

fix(tool-guardrails): detect content repetition across varying argument sets (#60084) - #60094

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:fix/60084-tool-guardrails-content-loop
Closed

fix(tool-guardrails): detect content repetition across varying argument sets (#60084)#60094
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:fix/60084-tool-guardrails-content-loop

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Summary

Add a content-hash-only repetition tracker to ToolCallGuardrailController that 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:

  1. Varying-args / fixed-result loop: A tool that "succeeds" with different arguments on every call but keeps returning the same blocked/empty/error-page body. The exact-failure counter never fires (failed is false), and the _no_progress tracker is scoped to idempotent tools only.
  2. Repeated multimodal results: A vision tool result embedding a base64 payload that makes str(result) unique on every call even when the meaningful content is identical.

Fix

A new _same_content_counts tracker keyed by result content hash only (no tool name, no args). Applied to ALL tools (not just idempotent ones) after the failure-clearing section in after_call().

New config knobs:

  • same_content_warn_after: 3 (default, via tool_loop_guardrails.warn_after.same_content)
  • same_content_block_after: 6 (default, via tool_loop_guardrails.hard_stop_after.same_content)

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #60087 — both add a content-hash-only tool-result repetition tracker to agent/tool_guardrails.py for #60084 (varying-args/fixed-result loops incl. multimodal dedup). Same mechanism/axis; #60087 (opened ~26 min earlier) is the canonical of the two. This is a distinct axis from #57851 (same-call-repeat). Maintainer to pick between #60087 and this.

…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
kyssta-exe force-pushed the fix/60084-tool-guardrails-content-loop branch from 8143934 to d29bde5 Compare July 7, 2026 19:33
@kyssta-exe

Copy link
Copy Markdown
Contributor Author

Stale — 7-8 days without merge activity. Can resubmit if still needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants