[BUG] Write tool includes full file content in tool_result system-reminder, doubling token cost

Resolved 💬 3 comments Opened May 1, 2026 by renne Closed May 4, 2026

Description

When the Write tool completes successfully, the entire file content is echoed back in a <system-reminder> block (injected into tool_result.content). This doubles the token cost of every file write — Claude already has the content in its context immediately before writing, so re-injecting it is pure overhead.

For small files (~1KB) the cost is negligible. But for files with 50–100+ lines (config files, scripts, generated docs), each Write call adds thousands of redundant tokens to the context window. In a session that writes many files, this compounds severely.

By contrast, the Edit tool returns only the change (the diff), not the full file.

Environment

  • Claude Code v2.4+ (current)
  • Platform: WSL2/Linux
  • Model: Sonnet 4.6

Steps to Reproduce

  1. Write any file with 50+ lines via the Write tool
  2. Inspect the resulting <system-reminder> — it contains the full file content

Expected Behavior

Write tool returns a compact success summary:

Wrote /path/to/file (N bytes, M lines)

Or at most a diff from the previous version (if file already existed).

Actual Behavior

Full file content is re-injected into context via <system-reminder>:

<system-reminder>
Called the Write tool. File written with content:
[full file content here — hundreds/thousands of tokens]
</system-reminder>

Impact

  • Context window: Each Write consumes 2× the tokens of the file size
  • Cache invalidation: The injected content shifts token positions, breaking prompt cache
  • Compound effect: A session writing 10 config files (avg. 80 lines each) wastes ~15–20k tokens on redundant echoes

Proposed Fix

Return only a one-line confirmation from Write. Claude already has the content in context — no need to echo it.

Alternatively: follow the Edit tool pattern and return only what changed.

Workaround

Use Edit instead of Write whenever possible (Edit only sends diffs). The system prompt already recommends this, but Write should ideally not penalize users who have legitimate reasons to use it (new files, complete rewrites).

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗