Repository navigation
fix(core): omit deprecated temperature param for Claude 4.8+ #6520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -744,9 +744,15 @@ export class AnthropicContentGenerator implements ContentGenerator { | |
| } | ||
| } | ||
|
|
||
| // Claude 4.8+ deprecated temperature — the server rejects it with a 400. | ||
| // Omit the parameter entirely for those models; older models keep the | ||
| // default of 1 (Anthropic's documented neutral value). | ||
| const temperatureValue = | ||
| getParam<number>('temperature', 'temperature') ?? 1; | ||
|
|
||
| return { | ||
| max_tokens: maxTokens, | ||
| temperature: getParam<number>('temperature', 'temperature') ?? 1, | ||
| ...(!this.modelRejectsTemperature() && { temperature: temperatureValue }), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two minor cleanups here — not bugs (
|
||
| top_p: getParam<number>('top_p', 'topP'), | ||
| top_k: getParam<number>('top_k', 'topK'), | ||
| }; | ||
|
|
@@ -858,6 +864,23 @@ export class AnthropicContentGenerator implements ContentGenerator { | |
| return major > 4 || (major === 4 && minor >= 7); | ||
| } | ||
|
|
||
| /** | ||
| * Whether the model rejects the `temperature` sampling parameter with a 400. | ||
| * Claude Opus 4.8+ deprecated temperature — the server controls sampling | ||
| * determinism internally and responds with | ||
| * `"temperature is deprecated for this model."` when the parameter is sent. | ||
| * Older models (4.7 and below) and unknown/unversioned ids still accept it, | ||
| * so both return false. | ||
| */ | ||
| private modelRejectsTemperature(): boolean { | ||
| const parsed = parseClaudeModelVersion( | ||
| this.contentGeneratorConfig.model || '', | ||
| ); | ||
| if (!parsed) return false; | ||
| const { major, minor } = parsed; | ||
| return major > 4 || (major === 4 && minor >= 8); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It mirrors |
||
| } | ||
|
|
||
| private buildThinkingConfig( | ||
| request: GenerateContentParameters, | ||
| effectiveEffort: ReasoningEffort | undefined, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] This only omits
temperaturefor4.8+, but Anthropic's Messages API docs saytemperature,top_p, andtop_kshould be omitted on Claude Opus 4.7 and later, including Opus 4.8. With the current request shape,claude-opus-4-7still sends configuredtemperature, andclaude-opus-4-8still sends configuredtop_p/top_k, so both paths can continue to return 400s after this fix.Please make this a sampling-parameter gate for the affected model set and apply it to all three fields; update the Opus 4.7 test to assert omission and add coverage for
topP/topK(and themajor > 4branch). See https://platform.claude.com/docs/en/build-with-claude/working-with-messages.— GPT-5 via Qwen Code /review