[BUG] /context command output appends to conversation history, causing immediate context inflation (~5k+ tokens)

Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened May 23, 2026 · closed May 23, 2026

Preflight Checklist

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

What's Wrong?

When checking system stats using the /context command, the CLI agent appends the detailed diagnostic text output (including listed MCP tools, memory file paths, and built-in skills) directly into the message history thread. Because LLM execution is stateless, subsequent turns must send this entire generated output block back to the API model. This results in an immediate, compounding token tax just for inspecting state.

What Should Happen?

Suggested resolution:
Telemetry commands like /context or /mcp should ideally write their UI/diagnostic output directly to the local terminal buffer without appending that generated output text to the active conversation history payload (Messages), preserving the user's available context window for actual development.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce:

  1. Run /context in an active session. Note the token count under Messages.
  2. Immediately run /context a second time without any other commands or code modifications.
  3. Observe that Messages usage jumps significantly (in this example, an immediate increase of 5.1k tokens), and available Free space drops accordingly.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

v2.1.148

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

5 Comments

github-actions[bot] · 3 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/49335

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

LostBeard · 3 months ago

While this is tracking the same architectural area as #49335, that issue is framed as a long-term feature request. I am filing this explicitly as a Bug Report / Resource Leak.

As the issue states, running local telemetry macro commands like /context injects thousands of static UI tokens directly into the active session history payload. This forces subsequent requests to upload that massive static text block back to the API, immediately burning through user usage quotas and context windows. Local diagnostic utilities should write to stdout out-of-band rather than polluting the conversation state. This is an active bug causing resource inflation, not a feature request.

cnighswonger · 3 months ago

@LostBeard same root cause as #49335 (tumes, 2026-04-16) — /release-notes and /context both bleed into conversation history. Worth closing this one as duplicate and 👍-ing the existing thread; tumes's report has more detail on the /release-notes cursor-position angle that compounds the cost.

LostBeard · 3 months ago

Closing as a duplicate of #49335 to consolidate tracking under the main thread.

Dropping a final note here for the fix context: While #49335 highlights the /release-notes cursor angle, the critical failure behavior to watch out for during the refactor is the absolute lack of token isolation for local macro utilities like /context.

Local environment diagnostics should stream directly to stdout out-of-band. Moving forward, allowing any purely local diagnostic command to append thousands of static UI tokens to the persistent active conversation payload creates an immediate resource leak that rapidly exhausts user API usage quotas and context windows on subsequent turns. Moving over to 👍 the main thread.

github-actions[bot] · 1 month ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.