Hook API should expose context window size

Resolved 💬 2 comments Opened Mar 31, 2026 by kriswill Closed Mar 31, 2026

Summary

The hook payload (stdin JSON) for both PostToolUse and Stop events does not include the context window size for the current session. This makes it impossible for hooks to accurately determine whether the session is using a 200K or 1M context window.

Current state

  • The transcript stores message.model as a bare model ID (e.g., claude-opus-4-6), with no context tier information
  • The system prompt contains text like "Opus 4.6 (with 1M context)" and the model ID claude-opus-4-6[1m], but this is not available in the transcript or hook payloads
  • Token usage (input_tokens, output_tokens, cache_*) is available per assistant message in the transcript

Problem

The same model ID (claude-opus-4-6) is used for both 200K and 1M context windows depending on the subscription tier (Standard vs Max/Enterprise). Without the context cap in the payload, hooks must either:

  1. Hardcode a lookup table and guess (wrong for Enterprise users)
  2. Use heuristics (e.g., if peak turn context > 200K, assume 1M)
  3. Require manual user configuration

None of these are reliable.

Proposed solution

Include the context window size in the hook payload, e.g.:

{
  "session_id": "...",
  "model": "claude-opus-4-6",
  "context_window": 1000000,
  ...
}

Alternatively, include it in the transcript entry metadata or use the qualified model ID (claude-opus-4-6[1m]) in message.model.

View original on GitHub ↗

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