[Feature] Expose current model name and context window size in session metadata

Resolved 💬 3 comments Opened May 15, 2026 by zmainen Closed May 19, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

There is no programmatic way to query a running Claude Code session's current model name and context window size (200k vs 1M).

What I've tried:

  • ~/.claude/sessions/*.json — has sessionId, pid, agent, cwd, version but no model or contextWindow fields
  • JSONL assistant message model field — says claude-opus-4-6 for both 200k and 1M (doesn't encode context size)
  • Scrollback scanning for "1M context" text from /model output — unreliable, scrolls off in long sessions
  • Token count heuristic (if >195k tokens, must be 1M) — works but is a hack

Use case: I'm building puppet-mcp, a tmux-based multi-session orchestrator. It needs to monitor context budget across 10+ concurrent sessions and warn before hitting the wall. Without knowing whether a session is on 200k or 1M, the warning thresholds are wrong.

Related: #51382 (expose session metadata), #45169 (subagent strips [1m] suffix)

Proposed Solution

Add model and contextWindow fields to ~/.claude/sessions/{PID}.json:

{
  "pid": 12345,
  "sessionId": "abc-def-...",
  "agent": "haak",
  "model": "claude-opus-4-6",
  "modelAlias": "opus[1m]",
  "contextWindow": 1000000,
  ...
}

contextWindow is the effective context window in tokens. modelAlias is the alias as specified (preserving the [1m] suffix). These should update when the user changes model via /model.

Alternative: expose via the statusLine hook data or a local API endpoint. Any machine-readable source would work.

Environment

  • Claude Code version: 2.1.142
  • OS: macOS
  • Terminal: tmux (orchestrating multiple sessions)

View original on GitHub ↗

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