Feature request: expose current model identity to hooks (no reliable way to detect a model change)
Open 💬 0 comments Opened Jul 13, 2026 by CountingJacks
I'm building hook-based automation that needs to react when the active model changes for a session (e.g., re-running a validation suite, invalidating a cache). There's no documented way to do this reliably. What I checked:
- No hook event or payload field carries model identity. None of the documented events (
PreToolUse,PostToolUse,UserPromptSubmit,Stop,SubagentStop,SessionStart,SessionEnd,PreCompact,Notification) include amodelfield in their JSON payload, and no environment variable exposes it to a hook script either. ~/.claude.json'sprojects.<path>.lastModelUsagecontains per-model usage stats, but it's undocumented internal state, not a stable API — and it's unsuitable anyway: it aggregates every model used against a project (including background sub-agent/compaction calls) with no way to tell which one is "the interactive model," and it doesn't reliably reflect the just-started session's model (confirmed live — it lagged behind the actual running model).- The session transcript's per-message
modelfield is precise, but aSessionStarthook fires before the new session has written any message, so it can't be read at start — and no event fires on a mid-session/modelswap at all.
Ask: a documented model field in the SessionStart (and/or PreToolUse/PostToolUse) hook payload, or a dedicated hook event on model change, so automations can detect and react to model swaps without relying on undocumented internal state.