fix: force temperature=1 when thinking is enabled or adaptive#1
Merged
dotCipher merged 1 commit intoMar 23, 2026
Merged
Conversation
Owner
|
Thanks @mateusz28011 — verified this against the API. |
dotCipher
added a commit
that referenced
this pull request
Mar 23, 2026
Fixes Anthropic API rejection when OpenCode sends a custom temperature with adaptive thinking active. Credit: @mateusz28011 (#1)
Owner
|
Released in v1.5.0. Upgrade: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
temperature may only be set to 1 when thinking is enabled or in adaptive modeAPI errorthinking: { type: "adaptive" }for non-Haiku models, but forwards the originaltemperaturevalue unchanged — Anthropic rejects any value other than1(or omitted) when thinking is activeChange
After the existing thinking injection block in the fetch wrapper, adds a guard that forces
temperature = 1when:thinking.typeis"enabled"or"adaptive", ANDtemperatureis explicitly set to something other than1If
temperatureis not present in the body at all, it is left untouched (the API defaults to1).Testing
Verified on OpenCode 1.2.27 with Claude Sonnet 4.6 via OAuth — the error no longer occurs.
Reference
https://docs.claude.com/en/docs/build-with-claude/extended-thinking#important-considerations-when-using-extended-thinking