Skip to content

fix(tool-guardrails): detect content-repetition loops across varying args (#60084) - #60219

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

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

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Problem

The tool-loop guardrails in agent/tool_guardrails.py miss two loop shapes:

  1. Varying-args / fixed-result loops: A tool call succeeds with different arguments on every call but keeps returning the same blocked/empty/error-page body. The existing _no_progress tracker is keyed by ToolCallSignature (tool name + args hash), so varying args resets the counter.
  2. Repeated multimodal results: A vision tool result embeds a unique base64 payload every call, making str(result) unique even when the meaningful content is identical.

Fix

  • Adds _semantic_result_hash() that strips base64 multimodal payloads before hashing, so vision-tool image reloads are detected
  • Adds _strip_multimodal_content() that recursively replaces large base64 strings and _multimodal=True content blocks with placeholder markers
  • Adds a _content_repetition tracker in ToolCallGuardrailController that 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 #60084

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

Copy link
Copy Markdown

This was generated by AI during triage.

Duplicate of #60087 — same content-hash-only result-repetition axis for #60084 in agent/tool_guardrails.py (both strip multimodal payloads before hashing and track (tool, semantic_hash) -> count), differing only in tracker/knob names. #60087 is the earliest-open version. Siblings #60148/#60094 already deduped into #60087.

@kyssta-exe

Copy link
Copy Markdown
Contributor Author

Stale — 6-7 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.

[Bug]: Tool-loop guardrails miss loops where args vary but the result never changes (incl. repeated multimodal results)

2 participants