{"version":"2.1.251","anchor":"new-premodelswitch-and-postmodelswitch-hooks","canonical_anchor":"new-premodelswitch-and-postmodelswitch-hooks","heading":"New PreModelSwitch and PostModelSwitch hooks","tier":"use","area":"Hooks","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.251\/e\/new-premodelswitch-and-postmodelswitch-hooks","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.251","markdown":"### New PreModelSwitch and PostModelSwitch hooks\n\nNew PreModelSwitch and PostModelSwitch hooks let you gate or annotate every model change.\n\n**What**\n\nTwo hook events now fire around model changes. PreModelSwitch runs before a switch from `\/model`, the model picker, the SDK or a resume, and can allow, deny or ask via `permissionDecision` (or block with exit code 2); deny cancels the switch and ask prompts for confirmation, except in headless sessions where it refuses. PostModelSwitch runs after the model changes and can inject `additionalContext` that reaches the model on the next request.\n\n**Details**\n\n- Registered in the hook schema, the `\/hooks` help text and the plugin hook-name validator, with their own dispatch and timeout handling.\n- Switch telemetry reports `from_model`, `to_model`, `requested_model`, whether the prompt cache is still warm, `cache_ttl`, an `estimated_cache_write_usd` re-caching estimate, and a `source` field distinguishing command, picker, sdk, auto and resume switches.\n\n**Evidence**\n\n`hookEventName: N(\"PreModelSwitch\")`, `PreModelSwitch`, `PreModelSwitch: [],\n\nPostModelSwitch: [],`, `PreModelSwitch: fdt`\n\n- Area: Hooks\n- Names: `PreModelSwitch`, `PostModelSwitch`, `permissionDecision`, `additionalContext`\n- Tier: Use it now\n- Useful: 5\/5\n- Signal: 4\/5"}