context_window.remaining_percentage leaks across sessions when switching models

Resolved 💬 3 comments Opened Mar 20, 2026 by gamiq-io Closed Mar 23, 2026

Description

When switching the model in one Claude Code session (e.g., to Sonnet 4.6 with 200k context), the context_window.remaining_percentage value reported in another concurrent session (running Opus 4.6 with 1M context) drops to 0%. Additionally, the Opus session's statusline starts displaying Sonnet as the active model — even though the session was not changed.

Steps to Reproduce

  1. Open two Claude Code terminal sessions simultaneously
  2. Session A: running with Opus 4.6 (1M context), statusline shows ~85% remaining
  3. Session B: switch model to Sonnet 4.6 (200k context) via /model sonnet
  4. Observe Session A (still intended to be on Opus 1M):
  • Statusline now shows Sonnet 4.6 as the model (incorrect)
  • Statusline now shows 0% remaining context

Additional Condition

The 0% behavior in Session A only triggers when the Opus session's remaining context is below ~80%. When the Opus session still has more than ~80% remaining, the issue may not manifest or is less visible.

Expected Behavior

Each session should independently track its own model and context window size. Changing the model in Session B should have no effect on Session A's reported model name or context_window.remaining_percentage.

Actual Behavior

  • Session A's model display changes to Sonnet 4.6 (the model chosen in Session B)
  • Session A's context_window.remaining_percentage drops to 0%, likely because the context window size denominator is updated globally from 1M (Opus) to 200k (Sonnet), making Session A's token usage appear to exceed the window

Environment

  • Claude Code version: latest
  • OS: Linux (Ubuntu)
  • Statusline: custom shell script consuming model.display_name and context_window.remaining_percentage from JSON input

Notes

This appears to be a shared global state issue where both the active model and the context window size are not scoped per-session. Two concurrent sessions appear to share the same model/context state, with one session's /model change overwriting the other's values.

View original on GitHub ↗

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