Skip to content

[BUG] Hundreds of lines of modified file notes being injected into context on EVERY user message via <system-reminder> #16021

@designbyian

Description

@designbyian

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Update: I've just encountered this issue with files that were edited only by the agent, I hadn't touched them during the session. This means there's no reliable way to avoid the issue.

Update 2: As of at least version 2.1.70 this bug is now injecting the full contents of the edited file(s) into context each turn. It takes only one largeish file being edited to completely eat the context window in a handful of turns. The bug still happens on both agent and user edits.

I'm using Claude Code for VS Code on Windows. I also have the CLI version but I have not tested this issue there, from the behavior I'd guess it's extension specific.

For at least the last two weeks context has intermittently been getting used up suspiciously fast. I've just been writing it off as some sort of transient issue that would get fixed eventually. In addition the model has been strangely dumber than I'm used to, but not consistently. Weird but not easily reproducible. Definitely frustrating and harder to work with. Causes usage limits to be eaten up more quickly.

Then today the agent said something that made it all make sense. They mentioned some context I wasn't aware of and upon investigation, I discovered this:

In a session where I'd had the agent make some code modifications, and I then made my own changes to the same files, the changes were being injected into context after EVERY subsequent message I was sending, in this format:

<system-reminder> Note: [Full path and filename] was modified, either by the user or by a linter. This change was intentional, so make sure to take it into account as you proceed (ie. don't revert it unless the user asks you to). Don't tell the user this, since they are already aware. Here are the relevant changes (shown with line numbers): [All lines edited in the file here] </system-reminder>

Key points:

  • The reminders are added to every message the user sends following the edits
  • The reminders are 100's of lines of code and could easily be 1000's of lines because:
  • If the edits are in multiple places in the file, the reminders include all code between the first edit and the last. Thus if a small edit was made at the top of the file, and another at the bottom, the reminder injection includes the ENTIRE file
  • Reverting the user changes causes the message injection to stop
  • The reminders happen regardless of whether or not the file is open in the IDE, making it impossible to stop the behavior without reverting the changes or starting a new session
  • Unsurprisingly, the reminders cause subsequent simple back and forth chat to eat through the entire context window in a short time

This explains both the strange context usage in recent weeks and the agent drift.

I also discovered other context injections like:
<system-reminder> The TodoWrite tool hasn't been used recently. If you're working on tasks that would benefit from tracking progress, consider using the TodoWrite tool to track progress. Also consider cleaning up the todo list if has become stale and no longer matches what you are working on. Only use it if it's relevant to the current work. This is just a gentle reminder - ignore if not applicable. Make sure that you NEVER mention this reminder to the user </system-reminder>

Which is less egregious since injections like that only happen once, as opposed to every message. But after the former discovery I have no trust that these sorts of hacky injections won't eventually add up to dealbreaking context issues.

It's hard not to be frustrated by this as it's such as obvious bug, it should never have made it into production, and because the agent is instructed to hide it from the user, it took all this time to even notice it was happening. I had just adjusted my workflow to start a new session whenever context started getting eaten up unexplainably or the agent started going off the rails. I had to do this often enough that I was starting to wonder if I should switch to a different provider. Despite Codex being a somewhat less proficient assistant, at least I don't have to restart the session multiple times during simple tasks.

To other CC VS Code extension users: please confirm this behavior and post your results here so that it gets fixed quickly and we can go back to having a usable tool.

What Should Happen?

The harness shouldn't be injecting messages about edits along with every user message. I could see this behavior being useful as a one time injection after a user makes an edit, but it makes no sense to attach it to every subsequent message. In the case of a one time injection, at most it should include diffs (as opposed to, potentially, entire files) and really in order to accomplish the apparent goal of stopping the agent from interfering with user changes, or making it aware of them, it would really only need to include something like "user has edited [file], [Line Numbers]"

Error Messages/Logs

Steps to Reproduce

  • Use Claude Code for VS Code extension
  • Have the agent read/modify some files
  • Make manual changes to the same files in multiple locations
  • Observe context injections on all subsequent user messages unless/until the user changes have been reverted

Note: I was able to get the agent to let me know about the injections despite its instructions to hide them. Please Anthropic, don't go the way of other tools/providers and start instructing agents not to tell users more and more things. A big part of your demographic is developers, we need to understand the environment our tools are operating in. It was really just luck that I noticed this issue.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.75

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions