File change system-reminders inject full file contents repeatedly, context grows to 692K tokens

Resolved 💬 6 comments Opened Apr 4, 2026 by gentry-tran Closed Apr 4, 2026

TL;DR: Editing lots of files in a long session causes token usage to explode — full file contents get re-injected into context on every turn and never get cleaned up.

Bug

When files are modified during a Claude Code session, <system-reminder> blocks containing full file contents are injected into the conversation context. These reminders persist and accumulate — they are not removed after being acknowledged. In a long session with many file edits, the context window fills with repeated file contents.

Verified data from session transcript

Extracted from the session's .jsonl transcript (usage field on each assistant message):

  • Total input tokens processed: 424,620,034 (424M)
  • Context size at session end: 692,190 tokens (near the 1M limit)
  • Cache read tokens: 402,378,746 (the same content re-read on every turn)
  • Output tokens: 248,911

The context grew steadily from ~50K tokens to 692K tokens over 923 messages. The growth is primarily from accumulated system-reminder file change notifications — 17 modified files injecting ~42K tokens of file contents per turn.

Files injected as system-reminders (measured)

| File type | Tokens per injection |
|-----------|---------------------|
| Large markdown file (500 lines) | 14,400 |
| Medium markdown file (320 lines) | 3,605 |
| TypeScript hook (270 lines) | 2,700 |
| TypeScript tool (250 lines) | 2,519 |
| TypeScript tool (240 lines) | 2,374 |
| TypeScript hook (200 lines) | 2,032 |
| Text evidence file (135 lines) | 1,969 |
| Shell script (190 lines) | 1,941 |
| Skill definition (180 lines) | 1,805 |
| Text evidence file (100 lines) | 1,668 |
| Text evidence file (150 lines) | 1,422 |
| TypeScript hook (120 lines) | 1,207 |
| + 5 smaller files | 3,851 |
| Total per turn | ~42,298 |

Reproduction

  1. Start a Claude Code session
  2. Use the Edit/Write tool to modify 10+ files (any mix of .ts, .md, .sh, .txt)
  3. Continue the conversation for 20+ turns
  4. Check the .jsonl transcript — observe cache_creation_input_tokens and cache_read_input_tokens growing with each message
  5. The system-reminder blocks are visible in the conversation as <system-reminder>Note: {file} was modified...</system-reminder> containing full file contents

Caveat

The token numbers above are verified from the session transcript. However, I cannot confirm that file change notifications are the sole cause of context growth. Other factors may contribute: conversation history, tool call results, compacted context from earlier messages, skills list injections, and other system-reminders. The 42K per-turn estimate is based on measuring the file sizes on disk — I cannot directly measure the injection frequency or confirm it happens on every turn vs selectively.

Suggestion

  • File change reminders should be injected once after the modification, then dropped from context
  • Or: include only the diff, not the full file
  • Or: provide a setting to disable file change notifications for files the model itself modified (it already knows what it wrote)

Environment

  • Claude Code 2.1.81
  • macOS
  • 923-message session, 17 modified files

View original on GitHub ↗

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