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
modelfield. - 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
/modelswitch 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:
- Include the currently active model in the PreToolUse/PostToolUse hook input payload (e.g.
model: "claude-opus-4-8"), updated live after/modelswitches, or - Emit a hook event (or extend
UserPromptSubmit) when the model changes via/model, with old/new model in the payload, or - Expose the active model via an environment variable that hook subprocesses inherit, updated on every
/modelswitch.
Any of the three would let hooks reliably gate tool use based on the active model — currently not possible.