You set up an automated background subagent, head off to grab a flat white,
and come back to discover it silently upgraded itself to Opus 5 mid task.
Suddenly your API bill looks like a phone number.
Oh yeah, that surprise context shift will get you every time.
Before we dive into how to lock that down, today's episode is brought to you by
Jellypod AI, the easiest way to turn your written content into high quality audio
podcasts.
So, Anthropic dropped version 2 point 1 point 251 for Claude Code on August 28,
2026, and it finally gives us proper brakes for model jumping.
Yeah, the big news is two lifecycle hook events, PreModelSwitch and PostModelSwitch.
Plus, when you resume a session with SessionStart, you now get session staleness
metrics and estimated re cache costs right in the payload.
Walk me through PreModelSwitch though.
How does that stop my agents from spending all my gold bullion?
It fires synchronously right before any model transition happens.
So if an agent tries to bump up from Haiku to Opus, platform engineers can catch it,
demand developer confirmation in the terminal, or just outright block it in CI CD
pipelines.
Ah, that's beautiful mate.
You can also attach custom audit annotations to your team telemetry logs so you know
who requested the upgrade and why.
Exactly.
Setting it up is super straightforward.
In your project, you open up dot claude slash hooks dot json and point a
PreModelSwitch handler to a validation script, say validate model dot py.
Right, the script checks the target model ID from the event payload,
and if it breaks your team policy, you just exit with code 1 or return a denial JSON
object.
Boom, request blocked.
Just watch out for edge cases though.
If you block model switches too aggressively, you will break subagent workflows that
legitimately need higher reasoning models to fix a complex bug.
Yeah, fair call.
And while SessionStart gives you re cache cost estimates on resume,
if your prompt shifted massively while you were away, you're still hitting a full
cold cache miss regardless.
True.
But there are some slick quality of life tweaks in this release too.
The slash cost command now breaks down your prompt cache hit ratios between warm and
cold tokens.
Plus slash effort now remembers your preference per model, so you don't have to keep
resetting it.
And you get direct CLI management commands like claude attach with session ID,
stop, respawn, and rm.
No more hunting down rogue background processes manually.
You have full command line governance from top to bottom.