Skip to content

fix(bedrock): omit temperature for Claude Opus 4.7+ when thinking is off#2601

Open
kimnamu wants to merge 2 commits into
logancyang:masterfrom
kimnamu:fix/bedrock-opus-4-7-temperature
Open

fix(bedrock): omit temperature for Claude Opus 4.7+ when thinking is off#2601
kimnamu wants to merge 2 commits into
logancyang:masterfrom
kimnamu:fix/bedrock-opus-4-7-temperature

Conversation

@kimnamu

@kimnamu kimnamu commented Jun 12, 2026

Copy link
Copy Markdown

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 REASONING capability is off (the default):

Amazon Bedrock streaming request failed with status 400:
{"message":"`temperature` is deprecated for this model."}

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 temperature parameter at all — Bedrock rejects any value, including the default. In BedrockChatModel.buildRequestBody(), the thinking-disabled branch always attached the resolved temperature:

} else {
  // Only set temperature if thinking is NOT enabled
  if (resolvedTemperature !== undefined) {
    payload.temperature = 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

  • Extract the existing Opus 4.7+ detection (previously inline in the thinking branch) into a small isOpus47OrNewer() helper, and reuse it.
  • In the thinking-disabled path, omit temperature for 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.

Before (current master) After (this PR)
before after
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:

Model Before After
Opus 4.8 / 4.7 ❌ 400 ✅ replies normally
Sonnet 4.6 / Haiku 4.5 ✅ works ✅ works (unchanged)
Opus 4.6 and earlier ✅ works ✅ works (unchanged)

I also confirmed the deprecation boundary directly against the Bedrock runtime API (only temperature differs between requests):

Request to us.anthropic.claude-opus-4-8 Result
temperature: 0.1 400 \temperature` is deprecated for this model.`
temperature omitted 200
temperature: 1 + thinking: adaptive 200

Tests

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 pins temperature: 1).

The new tests fail on master (they catch the bug) and pass with this fix:

Before (fix reverted, new tests run against current master logic):

✕ omits temperature for opus-4-7 when thinking is disabled
    expect(received).toBeUndefined()
    Received: 0.1
✕ omits temperature for opus-4-8 when thinking is disabled
    Received: 0.1
✕ omits temperature for opus-4-7 cross-region inference profiles
    Received: 0.7
✓ still sends temperature for opus-4-6 and earlier
✓ still sends temperature for sonnet-4-5 and haiku
✓ still sends temperature for dated Opus 4.0 snapshot IDs
Tests: 3 failed, 4 passed

After (this PR):

✓ omits temperature for opus-4-7 when thinking is disabled
✓ omits temperature for opus-4-8 when thinking is disabled
✓ omits temperature for opus-4-7 cross-region inference profiles
✓ still sends temperature for opus-4-6 and earlier
✓ still sends temperature for sonnet-4-5 and haiku
✓ still sends temperature for dated Opus 4.0 snapshot IDs
✓ forces temperature to 1 for opus-4-8 when thinking is enabled
Tests: 7 passed
  • npm test → all suites pass (added 7 tests).
  • npm run format / npm run lint → clean.
  • npm run build → type-check + bundle succeed.

Checklist

kimnamu and others added 2 commits June 12, 2026 10:12
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>
@kimnamu

kimnamu commented Jun 12, 2026

Copy link
Copy Markdown
Author

Hi @logancyang, thank you again for maintaining Copilot and for taking the time to look at this. 🙏

I noticed the build (22.x) workflow hasn't run yet — I believe that's because this is my first contribution from a fork, so GitHub Actions needs a maintainer's approval to run. Whenever you have a moment, would you mind approving the workflow run? No rush at all, and I completely understand if you'd like to review the diff first.

For what it's worth, I ran the full checks locally and they pass:

  • npm test → all suites pass (added 7 regression tests for the Opus 4.7+ temperature handling)
  • npm run format and npm run lint → clean
  • npm run build → type-check + bundle succeed

I also loaded the build into Obsidian and confirmed the fix end-to-end against live Bedrock: chatting with us.anthropic.claude-opus-4-8 (reasoning off) returned a normal reply, where it previously failed with 400 \temperature` is deprecated for this model.`

Happy to make any changes you'd like — thanks so much for your time and for considering this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock: Claude Opus 4.7+ chat fails with 400 temperature is deprecated when reasoning is off

1 participant