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:

  1. No hook event or payload field carries model identity. None of the documented events (PreToolUse, PostToolUse, UserPromptSubmit, Stop, SubagentStop, SessionStart, SessionEnd, PreCompact, Notification) include a model field in their JSON payload, and no environment variable exposes it to a hook script either.
  2. ~/.claude.json's projects.<path>.lastModelUsage contains 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).
  3. The session transcript's per-message model field is precise, but a SessionStart hook 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 /model swap 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.

View original on GitHub ↗