claude-code - 💡(How to fix) Fix [BUG] /context dumps the rendered ASCII widget into conversation context (~1.6k tokens per call) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55616Fetched 2026-05-03 04:48:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

When the user runs /context, the entire rendered TUI widget — including the ~400 box-drawing glyphs (, , , ) used for the visual fill bar — is captured as the slash command's output and injected verbatim into the conversation as a tool/command result the model sees on the next turn.

Each /context call adds roughly 1.6k tokens of pure visualization noise to the message history. Three checks ≈ 5k tokens. The tool whose entire purpose is to help users monitor context usage is itself one of the most expensive context-consuming operations in the harness.

This is the same class of bug as #44808 (/release-notes injecting full changelog).

Root Cause

When the user runs /context, the entire rendered TUI widget — including the ~400 box-drawing glyphs (, , , ) used for the visual fill bar — is captured as the slash command's output and injected verbatim into the conversation as a tool/command result the model sees on the next turn.

Each /context call adds roughly 1.6k tokens of pure visualization noise to the message history. Three checks ≈ 5k tokens. The tool whose entire purpose is to help users monitor context usage is itself one of the most expensive context-consuming operations in the harness.

This is the same class of bug as #44808 (/release-notes injecting full changelog).

Code Example

claude --system-prompt "x" --strict-mcp-config --tools "" --disallowedTools "LSP"

---

> hello
> /context     # Messages: 145 tokens
> /context     # Messages: 1.6k tokens   (+1.5k just from the previous widget)
> /context     # Messages: 3.2k tokens   (+1.6k more)

---

Context: 166/1,000,000 tokens (0.0%). System prompt: 21, System tools: 0, Messages: 145, Free: 999,834. Autocompact buffer: 33,000.
RAW_BUFFERClick to expand / collapse

Summary

When the user runs /context, the entire rendered TUI widget — including the ~400 box-drawing glyphs (, , , ) used for the visual fill bar — is captured as the slash command's output and injected verbatim into the conversation as a tool/command result the model sees on the next turn.

Each /context call adds roughly 1.6k tokens of pure visualization noise to the message history. Three checks ≈ 5k tokens. The tool whose entire purpose is to help users monitor context usage is itself one of the most expensive context-consuming operations in the harness.

This is the same class of bug as #44808 (/release-notes injecting full changelog).

Repro

claude --system-prompt "x" --strict-mcp-config --tools "" --disallowedTools "LSP"

Then in the TUI:

> hello
> /context     # Messages: 145 tokens
> /context     # Messages: 1.6k tokens   (+1.5k just from the previous widget)
> /context     # Messages: 3.2k tokens   (+1.6k more)

Each invocation adds ~1.6k tokens to Messages, perfectly correlated with the size of the rendered widget echoed into history.

Why it's so expensive

The grid uses Unicode glyphs outside common BPE vocab. Each / is a 3-byte UTF-8 codepoint that tokenizes to ~3 tokens. ~400 cells × ~3 tokens + chrome ≈ 1.5k tokens per render — for information that fits in a 25-token sentence.

Suggested fix

Split the renderer from the tool-result payload. Render the pretty grid for the user's terminal; send the model a structured-data summary instead, e.g.:

Context: 166/1,000,000 tokens (0.0%). System prompt: 21, System tools: 0, Messages: 145, Free: 999,834. Autocompact buffer: 33,000.

Same information, ~25 tokens vs ~1,600. ~64× cheaper, and arguably more useful to the model since it doesn't have to mentally OCR ASCII art back into numbers.

The same pattern likely applies to any other slash command whose output is a TUI visualization (/cost, /status, etc.) — worth auditing.

Environment

  • Claude Code v2.1.126 (native installer, macOS arm64)
  • Opus 4.7 (1M context)

Related

  • #44808 — /release-notes injects full changelog (same bug class)
  • #48269 — /context category breakdown double-counts Messages (the counter itself is also lying, separately)

extent analysis

TL;DR

Split the renderer from the tool-result payload to reduce the output size of the /context command.

Guidance

  • Identify and separate the rendering of the TUI widget from the tool-result payload to prevent unnecessary data from being injected into the conversation.
  • Consider sending a structured-data summary to the model instead of the full visualization, as suggested in the issue.
  • Audit other slash commands with TUI visualizations (e.g., /cost, /status) for similar issues.
  • Verify the fix by checking the output size of the /context command and ensuring it no longer adds excessive tokens to the message history.

Example

# Before
> /context     # Messages: 1.6k tokens

# After (suggested fix)
> /context     # Output: Context: 166/1,000,000 tokens (0.0%). System prompt: 21, System tools: 0, Messages: 145, Free: 999,834.

Notes

The suggested fix assumes that the rendering of the TUI widget can be separated from the tool-result payload without affecting the functionality of the /context command.

Recommendation

Apply the workaround by splitting the renderer from the tool-result payload, as it is likely to significantly reduce the output size of the /context command and improve performance.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] /context dumps the rendered ASCII widget into conversation context (~1.6k tokens per call) [1 comments, 2 participants]