7 pages for premodelswitch.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
Intercept and control agent behavior with hooks
Claude Code CLI · in the page
agent-sdk/hooks
…| Conversation compaction completes | Log the generated summary | | [`PreModelSwitch`](https://code.claude.com/docs/en/hooks#premodelswitch) | No | Yes | A requested model switch, before it happens (c…
Agent SDK reference - TypeScript
Claude Code CLI · in the page
agent-sdk/typescript
…gentStart" | "SubagentStop" | "PreCompact" | "PostCompact" | "PreModelSwitch" | "PostModelSwitch" | "PermissionRequest" | "PermissionDenied" | "Setup" | "TeammateIdle" | "TaskCreat…
Error reference
Claude Code CLI · in the page
errors
…#cant-switch-to-the-default-model) | | `Model switch ... blocked by a PreModelSwitch hook` | [Request errors](#model-switch-was-blocked-by-a-premodelswitch-hook) | | `couldn't save it as your default`…
Hooks reference
Claude Code CLI · in the page
hooks
…dChanged, FileChanged, and DirectoryAdded as standalone async events, PreModelSwitch as a standalone sequential event that runs before a requested model switch, PostModelSwitch as a standalone async e…
Automate actions with hooks
Claude Code CLI · in the page
hooks-guide
…ompaction | | `PostCompact` | After context compaction completes | | `PreModelSwitch` | Before Claude Code applies a model switch that you or a client requested. Can block the switch | | `PostModelSwi…
Model configuration
Claude Code CLI · in the page
model-config
…variables the host overrides. If you or your organization configure [PreModelSwitch hooks](https://code.claude.com/docs/en/hooks.md#premodelswitch), they run before a requested switch applies and can…
How Claude Code uses prompt caching
Claude Code CLI · in the page
prompt-caching
…d expired. You can also require this confirmation or skip it with a [PreModelSwitch hook](https://code.claude.com/docs/en/hooks.md#premodelswitch-decision-control). The [`opusplan` model setting](ht…