fix(tools): return read_file dedup hint in error field, not content (#13079)#13098
Open
dingn42 wants to merge 1 commit into
Open
fix(tools): return read_file dedup hint in error field, not content (#13079)#13098dingn42 wants to merge 1 commit into
dingn42 wants to merge 1 commit into
Conversation
…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>
Collaborator
1 similar comment
Collaborator
This was referenced Apr 22, 2026
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
When the same
read_filecall hit the in-memory dedup cache, the tool returned the skip hint in thecontentfield. Downstream tooling — in particular_subdirectory_hints.check_tool_callinrun_agent.py— treatscontentas 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
errorinstead. Thededup: Trueflag is preserved so callers that want to distinguish "skip" from a real error can still do so, but consumers that routecontentanderrordifferently (including anything that line-number-prefixes file text) can no longer confuse the stub for file content.Test plan
test_second_read_returns_dedup_stubto assert the new contract (nocontentkey, hint text lives inerror).pytest tests/tools/test_file_read_guards.py tests/tools/test_file_operations.py— 67 passed.{dedup: true, error: "SKIP: File unchanged..."}with nocontentkey; first reads and post-modification reads still return normal content.