Sonnet 5 migration is not the drop-in upgrade Anthropic’s headline describes — at least not if your Sonnet 4.6 production code sets temperature, uses manual extended thinking, or has token budgets sized close to your expected output length.
Claude Sonnet 5 launched on June 30, 2026, and has been available on AWS, Azure Foundry, and the Claude Platform API since July 1. The official documentation describes it as “a drop-in upgrade for Claude Sonnet 4.6 with three behavior changes.” The framing undersells how disruptive two of those three changes are in practice: they are API contract changes that return hard errors, not soft behavioral shifts. A Sonnet 4.6 codebase can hit all three simultaneously, with zero warning until the first production request fails.

This post gives you the complete Sonnet 5 migration map — what breaks, why it breaks, and the exact code fix for each issue — before you push a single request to production.
Sonnet 5 Migration Breaking Change 1: Temperature Returns a 400 Error
On Claude Sonnet 5, setting temperature, top_p, or top_k to any non-default value returns a 400 error. The same constraint applies to Claude Opus 4.7 and 4.8 — but most Sonnet 4.6 users never updated their code to account for it because Sonnet 4.6 still accepted these parameters.
If your Sonnet 4.6 pipeline sets temperature explicitly — even to the default value of 1.0 — it will fail on Sonnet 5. Anthropic’s guidance is to remove the parameters entirely and use system-prompt instructions to guide sampling behavior instead.
import anthropic
client = anthropic.Anthropic()
# BREAKS ON SONNET 5: temperature parameter returns 400
# response = client.messages.create(
# model="claude-sonnet-5",
# max_tokens=1000,
# temperature=0.7, # ← 400 error
# messages=[{"role": "user", "content": "Write a Python function."}]
# )
# CORRECT: remove temperature entirely
# If you need deterministic behavior, say so in the system prompt
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=1000,
system="Be precise and deterministic. Avoid creative variation.",
messages=[{"role": "user", "content": "Write a Python function."}]
)
print(response.content[0].text)
Sonnet 5 Migration Breaking Change 2: Manual Extended Thinking Is Removed
Manual extended thinking — the pattern of setting thinking: {"type": "enabled", "budget_tokens": N} in your request — was deprecated on Sonnet 4.6 but still accepted. On Sonnet 5, it is fully removed and returns a 400 error immediately.
The replacement is adaptive thinking via the effort parameter: set it to "low", "medium", or "high" and Sonnet 5 manages its own reasoning budget. Adaptive thinking is also on by default on Sonnet 5 — meaning every request now runs with some level of internal reasoning even if you don’t specify an effort level. This changes latency and token consumption profiles for requests that previously ran without thinking enabled.
import anthropic
client = anthropic.Anthropic()
# BREAKS ON SONNET 5: manual budget_tokens returns 400
# response = client.messages.create(
# model="claude-sonnet-5",
# max_tokens=16000,
# thinking={"type": "enabled", "budget_tokens": 10000}, # ← 400 error
# messages=[{"role": "user", "content": "Solve this architecture problem."}]
# )
# CORRECT: use adaptive thinking with effort parameter
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=16000,
extra_body={"effort": "high"}, # "low", "medium", or "high"
messages=[{"role": "user", "content": "Solve this architecture problem."}]
)
# Adaptive thinking returns thinking blocks in content
for block in response.content:
if block.type == "thinking":
print(f"[THINKING] {block.thinking[:200]}...")
elif block.type == "text":
print(f"[OUTPUT] {block.text}")
Sonnet 5 Migration Breaking Change 3: The New Tokenizer Will Surprise Your Budget
The third change is not a hard error — it’s a cost and capacity surprise that arrives after you’ve already deployed. Sonnet 5 uses a new tokenizer that produces approximately 30% more tokens for the same input text. The exact increase depends on content type, but the direction is consistent: the same prompt that costs X tokens on Sonnet 4.6 will cost roughly 1.3X tokens on Sonnet 5.
Three consequences follow from this:
- The introductory pricing is not a real discount. Sonnet 5’s introductory price through August 31 is $2/$10 per million tokens, versus $3/$15 at standard rates and Sonnet 4.6’s $3/$15. The lower per-token rate approximately offsets the higher token count for the same text — making the transition roughly cost-neutral rather than cheaper.
- Your
max_tokensbudgets may now truncate output. If your Sonnet 4.6 code setsmax_tokensclose to your expected output length, Sonnet 5 may hit that limit before finishing the same output — because each token now covers slightly less text. Audit any pipeline where you’ve tunedmax_tokenstightly. - Do not reuse token counts measured against Sonnet 4.6. Cached context window capacity calculations, cost estimates, and rate limit projections all need to be remeasured against actual Sonnet 5 output for your specific workloads.
import anthropic
client = anthropic.Anthropic()
# Safe way to measure your actual token usage on Sonnet 5
# before committing to production — use count_tokens
test_messages = [{"role": "user", "content": "Your representative production prompt here."}]
token_count = client.messages.count_tokens(
model="claude-sonnet-5",
messages=test_messages,
)
print(f"Sonnet 5 token count: {token_count.input_tokens}")
# Compare against your Sonnet 4.6 baseline to measure the actual increase
# for your specific workload distribution
The AI Agent Unit Economics post in this series built a per-action cost tracker that catches exactly this kind of tokenizer-driven cost increase — run your actual workloads through that tracker against Sonnet 5 before scaling production traffic.
What Changed for the Better: Why the Sonnet 5 Migration Is Worth It
The breaking changes are real, but so is the upside. Sonnet 5 closes the gap with Opus 4.8 significantly on the workloads that matter most for agentic pipelines:
- Tool use and multi-step coherence are the headline improvements. The Sub-Agent Orchestration patterns in this series will see measurable reliability gains on complex chains where Sonnet 4.6 occasionally failed to maintain context across tool call sequences.
- The 1M token context window is now default, not beta. Pipelines that were processing large codebases or documents in chunks can now operate on the full context in a single pass.
- Lower rate limits complexity. Anthropic consolidated rate limit tiers from many to three — Start, Build, and Scale — and raised Sonnet limits to match Opus at every tier. The pipeline configuration complexity around rate limit management is reduced.
- Safety behavior improvements. Sonnet 5 shows a lower rate of undesirable behaviors in agentic contexts than Sonnet 4.6, and measurably lower cybersecurity task capability than Opus — which is the correct direction for most production pipelines that don’t need their Sonnet instance to be capable of advanced offensive security tasks.
The Sonnet 5 Migration Checklist
- Search your codebase for
temperature,top_p, andtop_kparameters. Remove them all. Move any sampling guidance into system prompts. - Search for
thinking: {"type": "enabled". Replace witheffort: "high"for complex reasoning tasks. Remove entirely where you don’t need extended thinking. - Recount your representative prompts against Sonnet 5 using
count_tokensbefore scaling traffic. Update anymax_tokensvalues that are sized close to expected output length. - Update your cost table in the Model Fallback Routing configuration to use
claude-sonnet-5as the primary model ID. The promotional rate ($2/$10) applies through August 31, after which standard rates ($3/$15) apply. - Run a canary deployment — shift 5 to 10% of traffic to Sonnet 5 while keeping Sonnet 4.6 as the fallback, verify behavior and cost, then promote fully once the canary is clean.
For the official migration reference, see Anthropic’s What’s New in Sonnet 5 documentation.
The Builder’s Takeaway
Sonnet 5 migration is worth doing — but it’s not the frictionless swap the launch announcement implies for teams running production Sonnet 4.6 code. The three breaking changes are specific, catchable, and fixable in an afternoon if you know what to look for. The tokenizer cost surprise is the one that will show up in next month’s invoice if you skip the canary and go straight to full traffic. Run the checklist above, validate on representative workloads, then promote. The performance gains on agentic tool-use tasks are real enough to justify the migration. The shortcuts around it are not.
This post is part of The Agentic Protocol’s Work series — the connective infrastructure layer beneath every autonomous pipeline. See also: Claude Sonnet 5.