Hooks cannot detect the active model or /model runtime switches

Open 💬 0 comments Opened Jul 9, 2026 by sven-s-ter

Problem
Hook scripts (PreToolUse, PostToolUse, etc.) have no way to determine which model is currently active in a session:

  • The PreToolUse/PostToolUse JSON payload contains no model field.
  • No environment variable exposes the active model to hook processes.
  • /model <name> changes the model for the current session only and is not persisted anywhere a hook can read (not in .claude/settings.local.json, not in any session-state file).
  • No hook event fires on a /model switch with the new model in its payload.

Impact
Teams practicing cost-disciplined model orchestration (e.g. defaulting to a cheap model, escalating to an expensive one only for hard sub-tasks, then de-escalating) cannot enforce this technically. A PreToolUse gate that should block code edits while an expensive model is active has no reliable signal to act on — even SessionStart's model field only reflects the model at session start/resume, not later /model switches.

Request
Either:

  1. Include the currently active model in the PreToolUse/PostToolUse hook input payload (e.g. model: "claude-opus-4-8"), updated live after /model switches, or
  2. Emit a hook event (or extend UserPromptSubmit) when the model changes via /model, with old/new model in the payload, or
  3. Expose the active model via an environment variable that hook subprocesses inherit, updated on every /model switch.

Any of the three would let hooks reliably gate tool use based on the active model — currently not possible.

View original on GitHub ↗