fix(bedrock): omit temperature for Claude Opus 4.7+ when thinking is off#2601
fix(bedrock): omit temperature for Claude Opus 4.7+ when thinking is off#2601kimnamu wants to merge 2 commits into
Conversation
Opus 4.7+ no longer accepts the `temperature` parameter — Bedrock rejects any value with `400 \`temperature\` is deprecated for this model.`. The thinking-disabled path in buildRequestBody() always attached the resolved temperature, so chatting with Opus 4.7/4.8 failed unless the REASONING capability happened to be enabled (that path pins temperature: 1, which Opus 4.7+ accepts alongside adaptive thinking). Extract the existing Opus 4.7+ detection into an isOpus47OrNewer() helper (previously inline in the thinking branch) and reuse it to skip temperature for those models when thinking is off. All other models keep their current behavior. Adds regression tests covering Opus 4.7/4.8 (bare + cross-region), Opus 4.6 and earlier, Sonnet/Haiku, and the dated Opus 4.0 snapshot ID. Fixes logancyang#2600 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The cross-region test was named for opus-4-7 but used an opus-4-8 ID. Switch to a fully-qualified dated cross-region profile (global.anthropic.claude-opus-4-7-20260115-v1:0) so the test name matches the data and follows the existing fixture style. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Hi @logancyang, thank you again for maintaining Copilot and for taking the time to look at this. 🙏 I noticed the For what it's worth, I ran the full checks locally and they pass:
I also loaded the build into Obsidian and confirmed the fix end-to-end against live Bedrock: chatting with Happy to make any changes you'd like — thanks so much for your time and for considering this! |
Thank you 🙏
Thanks so much for Copilot and the Amazon Bedrock provider — it's been great to use with Claude on AWS. This is a small fix for the latest Opus models.
Fixes #2600
Problem
With the Bedrock provider, chatting with Claude Opus 4.7 / 4.8 fails for every message when the model's
REASONINGcapability is off (the default):Opus 4.6 and earlier, Sonnet (4 / 4.5 / 4.6), and Haiku 4.5 are unaffected.
Root cause
Opus 4.7+ no longer accepts the
temperatureparameter at all — Bedrock rejects any value, including the default. InBedrockChatModel.buildRequestBody(), the thinking-disabled branch always attached the resolvedtemperature:The thinking-enabled path already special-cases Opus 4.7+ (adaptive thinking) and pins
temperature: 1, which Opus 4.7+ accepts alongside adaptive thinking — so the model only worked when reasoning was turned on. With reasoning off, it always 400s.Change
isOpus47OrNewer()helper, and reuse it.temperaturefor Opus 4.7+. Every other model keeps its current behavior, and the thinking-enabled path is untouched.The diff is intentionally minimal — no behavior change for any model other than Opus 4.7+ with thinking off.
Before / After (live Bedrock, Opus 4.8, reasoning off)
Same prompt (“What is the capital of France?”), same model (
us.anthropic.claude-opus-4-8), reasoning off — built this branch and loaded it into Obsidian.master)400 \temperature` is deprecated for this model.`The capital of France is Paris.(no console errors)Behavior across the rest of the lineup is unchanged:
I also confirmed the deprecation boundary directly against the Bedrock runtime API (only
temperaturediffers between requests):us.anthropic.claude-opus-4-8temperature: 0.1400 \temperature` is deprecated for this model.`temperatureomitted200temperature: 1+thinking: adaptive200Tests
Added a
temperature handling for Opus 4.7+suite covering Opus 4.7/4.8 (bare + cross-region), Opus 4.6 and earlier, Sonnet/Haiku, the dated Opus 4.0 snapshot ID (claude-opus-4-20250514, which must not be treated as 4.7+), and the thinking-enabled case (still pinstemperature: 1).The new tests fail on
master(they catch the bug) and pass with this fix:Before (fix reverted, new tests run against current
masterlogic):After (this PR):
npm test→ all suites pass (added 7 tests).npm run format/npm run lint→ clean.npm run build→ type-check + bundle succeed.Checklist
temperatureis deprecated when reasoning is off #2600)