Skip to content

Commit d8f6cc9

Browse files
committed
feat(bedrock): support Claude Opus 4.8 (extends 4.7 adaptive thinking detection)
- Anthropic provider: add claude-opus-4-8 to both prompt-caching switch statements so it gets the same handling as 4.7 (native 1M context, no beta header required). - Bedrock provider: rename isGen47Model -> isAdaptiveThinkingModel and expand the pattern to match opus-4-7, opus-4-8, sonnet-4-7, sonnet-4-8. 4.8 inherits the same adaptive-thinking + temperature-rejection contract from 4.7 with no breaking API changes. - OpenAI-compatible provider: update comment to mention 4.8 alongside 4.7; no logic change (already honors the supportsTemperature: false flag). The rename describes the capability (adaptive thinking) rather than a specific generation, making future Claude versions easier to support.
1 parent 1bcae71 commit d8f6cc9

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

src/api/providers/anthropic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
9393
case "claude-sonnet-4-20250514":
9494
case "claude-opus-4-6":
9595
case "claude-opus-4-7":
96+
case "claude-opus-4-8":
9697
case "claude-opus-4-5-20251101":
9798
case "claude-opus-4-1-20250805":
9899
case "claude-opus-4-20250514":
@@ -161,6 +162,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
161162
case "claude-sonnet-4-20250514":
162163
case "claude-opus-4-6":
163164
case "claude-opus-4-7":
165+
case "claude-opus-4-8":
164166
case "claude-opus-4-5-20251101":
165167
case "claude-opus-4-1-20250805":
166168
case "claude-opus-4-20250514":

src/api/providers/bedrock.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,19 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
392392
let additionalModelRequestFields: BedrockAdditionalModelFields | undefined
393393
let thinkingEnabled = false
394394

395-
// Detect model generation for API compatibility
396-
// Claude 4.7+ removed sampling params (temperature/top_p/top_k) and uses adaptive thinking
395+
// Detect models that require the adaptive-thinking API contract.
396+
// Starting with Claude Opus 4.7 (and the matching Sonnet 4.7), and continuing
397+
// in Opus 4.8 / Sonnet 4.8, Anthropic removed sampling parameters
398+
// (temperature/top_p/top_k) and replaced budget_tokens-based thinking with
399+
// `thinking.type: "adaptive"` plus `output_config.effort`. The migration guide
400+
// from 4.7 → 4.8 confirms there are no further breaking API changes, so we
401+
// keep a single guard here that matches both generations.
397402
const baseModelId = this.parseBaseModelId(modelConfig.id)
398-
const isGen47Model = baseModelId.includes("opus-4-7") || baseModelId.includes("sonnet-4-7")
403+
const isAdaptiveThinkingModel =
404+
baseModelId.includes("opus-4-7") ||
405+
baseModelId.includes("opus-4-8") ||
406+
baseModelId.includes("sonnet-4-7") ||
407+
baseModelId.includes("sonnet-4-8")
399408

400409
// Determine if thinking should be enabled
401410
// metadata?.thinking?.enabled: Explicitly enabled through API metadata (direct request)
@@ -408,9 +417,13 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
408417

409418
if ((isThinkingExplicitlyEnabled || isThinkingEnabledBySettings) && modelConfig.info.supportsReasoningBudget) {
410419
thinkingEnabled = true
411-
if (isGen47Model) {
412-
// Claude 4.7+ uses adaptive thinking with effort levels — budget_tokens causes 400 error
413-
// display: "summarized" surfaces thinking content in Zoo Code UI
420+
if (isAdaptiveThinkingModel) {
421+
// Claude 4.7+ (incl. 4.8) uses adaptive thinking with effort levels —
422+
// budget_tokens causes a 400 error.
423+
// display: "summarized" surfaces thinking content in Zoo Code UI.
424+
// effort "xhigh" remains the recommended level for agentic coding tasks
425+
// across both 4.7 and 4.8 (4.8 changed the API default to "high" but
426+
// the model continues to honour "xhigh" for deeper reasoning).
414427
additionalModelRequestFields = {
415428
thinking: { type: "adaptive", display: "summarized" },
416429
output_config: { effort: "xhigh" },
@@ -432,8 +445,9 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
432445

433446
const inferenceConfig: BedrockInferenceConfig = {
434447
maxTokens: modelConfig.maxTokens || (modelConfig.info.maxTokens as number),
435-
// Claude 4.7+ removed temperature parameter entirely — causes 400 error if sent
436-
...(isGen47Model
448+
// Claude 4.7+ (including 4.8) removed sampling parameters entirely —
449+
// sending temperature causes a 400 error.
450+
...(isAdaptiveThinkingModel
437451
? {}
438452
: { temperature: modelConfig.temperature ?? (this.options.modelTemperature as number) }),
439453
}

src/api/providers/openai.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
154154

155155
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
156156
model: modelId,
157-
// Some OpenAI-Compatible models (e.g. claude-opus-4-7) reject `temperature` as
158-
// deprecated/unsupported. Honor the model's `supportsTemperature` flag and omit it
159-
// when explicitly set to false (undefined still sends temperature, preserving behavior).
157+
// Some OpenAI-Compatible models (e.g. claude-opus-4-7, claude-opus-4-8) reject
158+
// `temperature` as deprecated/unsupported. Honor the model's `supportsTemperature`
159+
// flag and omit it when explicitly set to false (undefined still sends temperature,
160+
// preserving behavior).
160161
...(modelInfo.supportsTemperature !== false && {
161162
temperature:
162163
this.options.modelTemperature ?? (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0),

0 commit comments

Comments
 (0)