New PreModelSwitch and PostModelSwitch hooks let you gate or annotate every model change.
What's wrong with this entry?
Two 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.
- Registered in the hook schema, the
/hookshelp text and the plugin hook-name validator, with their own dispatch and timeout handling. - Switch telemetry reports
from_model,to_model,requested_model, whether the prompt cache is still warm,cache_ttl, anestimated_cache_write_usdre-caching estimate, and asourcefield distinguishing command, picker, sdk, auto and resume switches.
hookEventName: N("PreModelSwitch"), PreModelSwitch, `PreModelSwitch: [],
PostModelSwitch: [],, PreModelSwitch: fdt`
Strings lifted out of the shipped bundle, so the claim above can be checked against them.