Skip to content

fix(ai): suppress deprecated temperature param for Claude Opus 4.7+#5251

Merged
badlogic merged 1 commit into
earendil-works:mainfrom
yzhg1983:fix/anthropic-opus-temperature
May 31, 2026
Merged

fix(ai): suppress deprecated temperature param for Claude Opus 4.7+#5251
badlogic merged 1 commit into
earendil-works:mainfrom
yzhg1983:fix/anthropic-opus-temperature

Conversation

@yzhg1983

Copy link
Copy Markdown
Contributor

Summary

Suppress the Anthropic temperature request parameter for Claude Opus 4.7+ models.

Anthropic rejects non-default temperature values for these models with:

400 `temperature` is deprecated for this model.

pi does not set temperature by default, but programmatic callers and extensions can still pass temperature. This change prevents avoidable Anthropic 400s in that path.

Reference:

Changes

  • Add supportsTemperature?: boolean to AnthropicMessagesCompat.
  • Default supportsTemperature to true in the Anthropic compat layer.
  • Mark Claude Opus 4.7/4.8 Anthropic Messages models as supportsTemperature: false in generated metadata.
  • Omit temperature when supportsTemperature is false.
  • Add payload regression tests.

Test made:

  • cd packages/ai && node ../../node_modules/vitest/dist/cli.js --run test/anthropic-temperature-compat.test.ts
  • npm run check

@badlogic badlogic merged commit ad9081b into earendil-works:main May 31, 2026
3 checks passed
@badlogic

Copy link
Copy Markdown
Collaborator

cheers!

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.

2 participants