Skip to content

fix(tools): return read_file dedup hint in error field, not content (#13079)#13098

Open
dingn42 wants to merge 1 commit into
NousResearch:mainfrom
dingn42:fix/read-file-dedup-pollution
Open

fix(tools): return read_file dedup hint in error field, not content (#13079)#13098
dingn42 wants to merge 1 commit into
NousResearch:mainfrom
dingn42:fix/read-file-dedup-pollution

Conversation

@dingn42

@dingn42 dingn42 commented Apr 20, 2026

Copy link
Copy Markdown

Problem

When the same read_file call hit the in-memory dedup cache, the tool returned the skip hint in the content field. Downstream tooling — in particular _subdirectory_hints.check_tool_call in run_agent.py — treats content as literal file text with line-number prefixes, which allowed the hint to splice into the file payload and nest across repeated reads, eventually corrupting what the model sees.

Fixes #13079.

Fix

Return the dedup hint in error instead. The dedup: True flag is preserved so callers that want to distinguish "skip" from a real error can still do so, but consumers that route content and error differently (including anything that line-number-prefixes file text) can no longer confuse the stub for file content.

Test plan

  • Updated test_second_read_returns_dedup_stub to assert the new contract (no content key, hint text lives in error).
  • pytest tests/tools/test_file_read_guards.py tests/tools/test_file_operations.py — 67 passed.
  • Reran the Python reproducer from the issue: second read returns {dedup: true, error: "SKIP: File unchanged..."} with no content key; first reads and post-modification reads still return normal content.

…ousResearch#13079)

When the same ``read_file`` call hit the in-memory dedup cache the tool
returned the skip hint in the ``content`` field. Downstream tooling —
e.g. ``_subdirectory_hints.check_tool_call`` in run_agent.py — treats
``content`` as literal file text with line-number prefixes, which
allowed the hint to splice into the file payload and nest across
repeated reads.

Return the hint in ``error`` instead, matching every other skip/guard
path in this file, so consumers that route ``error`` and ``content``
differently can never confuse the dedup stub for file content.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/tools Tool registry, model_tools, toolsets tool/file File tools (read, write, patch, search) labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

#13210 is a duplicate of this PR — same fix for #13079.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

#13210 is a duplicate of this PR — same fix for #13079.

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

Labels

comp/tools Tool registry, model_tools, toolsets P1 High — major feature broken, no workaround tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: read_file tool's dedup mechanism pollutes file content with cache hint text

2 participants