fix(provider): send enabled thinking for Claude Opus 4.5 across Anthropic, Vertex, Bedrock, and SAP - #12548
Closed
rakshith1928 wants to merge 6 commits into
Closed
Conversation
…rtex
Replace the bare '{effort}' Opus 4.5 payload with an explicit '{thinking: {enabled, budgetTokens}, effort}' shape on the Anthropic and Vertex-native (@ai-sdk/anthropic / @ai-sdk/google-vertex/anthropic) branches, matching upstream PR #38757. Adds two new helpers anthropicOpus45 and anthropicOpus45Effort. Updates the shared transform.test.ts Opus 4.5 row to assert the new shape and adds Kilo-owned regression coverage in test/kilocode/transform-opus-4.5.test.ts. Bedrock and SAP paths are addressed in follow-up commits.
Insert a Bedrock-specific Opus 4.5 branch before the generic Anthropic-budget block in the @ai-sdk/amazon-bedrock case. Produces a 3-effort variant set with '{reasoningConfig: {type: enabled, budgetTokens, maxReasoningEffort}}', matching the upstream shape. Closes the Bedrock gap left by the previous commit.
Insert a SAP AI Core Opus 4.5 branch before the generic high/max fallback inside the @jerome-benoit/sap-ai-provider-v2 case. Produces a 3-effort variant set wrapped in modelParams with snake_case thinking {type: enabled, budget_tokens} + bare effort. Completes the Opus 4.5 enabled-thinking rollout across Anthropic, Vertex, Bedrock, and SAP providers. Also trims redundant parenthetical notes on existing kilocode_change marker comments.
Documents the user-facing behavior change: Opus 4.5 now sends enabled extended thinking + effort across Anthropic, Vertex, Bedrock, and SAP AI Core providers so the reasoning effort picker actually engages Opus 4.5's legacy thinking budget.
…ures Dedupe the enabled-thinking budget calculation across Anthropic, Bedrock, and SAP branches into a shared anthropicOpus45BudgetTokens helper, and replace the any-typed mockModel in the Opus 4.5 fixture with a typed Provider.Model constructor using ModelV2.ID.make / ProviderV2.ID.make so override sites get real type-checking.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous Review Summary (commit 9412dc4)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 9412dc4)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Reviewed by claude-sonnet-5 · Input: 20 · Output: 2.8K · Cached: 394K Review guidance: REVIEW.md from base branch |
…igh row The inline \// kilocode_change - <text>\ form only covers its own line, so the expectedHigh change line it sat above was left unannotated and CI's annotation check flagged it. Switch to the \kilocode_change start\ / \kilocode_change end\ block form so the row between them is covered.
Collaborator
|
thanks, but we'll inherit anomalyco/opencode#38757 when we merge the upstream |
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.
Issue
Fixes #12546
Context
Why: KiloCode currently sends only the
effortparameter for Claude Opus 4.5. Anthropic's adaptive-thinking documentation states that older models such as Claude Opus 4.5 do not support adaptive thinking and requirethinking: { type: "enabled", budget_tokens }alongsideeffort. Sending effort alone does not enable extended thinking on Opus 4.5 because Anthropic requires thinking: { type: "enabled", budget_tokens } alongside effort.Reference:
1.https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking
2.anomalyco/opencode#38757 ("fix(provider): generalize Claude adaptive thinking") Thanks to them.
The Opus 5 routing portion of that upstream PR is tracked separately in #12544 and is intentionally not duplicated here.
Scope is restricted to Opus 4.5; no other Claude family is affected.
Implementation
Added two new helpers in
packages/opencode/src/provider/transform.ts(afteranthropicOmitsThinking):anthropicOpus45(apiId)— matches IDs containingopus-4-5oropus-4.5.anthropicOpus45Effort(model, effort)— returns{ thinking: { type: "enabled", budgetTokens: min(16_000, floor(output / 2 - 1)) }, effort }.Then wired the helper into the three provider branches that previously mishandled Opus 4.5:
case "@ai-sdk/anthropic": case "@ai-sdk/google-vertex/anthropic":): replaced the bare{ effort }literal branch with a call toanthropicOpus45Effort(model, effort).case "@ai-sdk/amazon-bedrock":): inserted a new branch before the genericapi.id.includes("anthropic")legacy block. Emits{ reasoningConfig: { type: "enabled", budgetTokens, maxReasoningEffort: effort } }to match Bedrock's adaptive-branch shape.case "@jerome-benoit/sap-ai-provider-v2":): inserted a new branch before the generic{ high, max }fallback. Uses snake_casebudget_tokens(SAP's existing convention at that call site) and wraps each variant inmodelParamsvia the existingwrapInSapModelParamshelper.The budget formula
Math.min(16_000, Math.floor(model.limit.output / 2 - 1))is identical to upstream PR #38757'santhropicOpus45Effort. The default mock model in tests hasoutput: 64_000, sobudgetTokenssaturates to16000in regression tests.Screenshots / Video
N/A — pure backend/provider transform change; no UI diff.
How to Test
Manual/local verification
thinking: { type: "enabled", budget_tokens }alongsideeffort(Anthropic/Vertex/SAP) orreasoningConfig: { type: "enabled", budgetTokens, maxReasoningEffort }(Bedrock).Reviewer test steps
cd packages/opencode && bun test ./test/kilocode/transform-opus-4.5.test.ts— 5 cases across 4 providers (claude-opus-4-5-20251101,claude-opus-4.5-20251101on Anthropic;claude-opus-4-5@defaulton Vertex;us.anthropic.claude-opus-4-5-20251101-v1:0on Bedrock;anthropic--claude-opus-4-5-20251101on SAP).cd packages/opencode && bun test ./test/provider/transform.test.ts— confirm the existingopus 4.5row in the shared parametrized array now passes with the new{ thinking: { type: "enabled", budgetTokens: 16000 }, effort: "high" }shape and that all other rows (Opus 4.7/4.8, Sonnet 4.6, Sonnet 5, Fable 5) are unchanged.bun run script/check-opencode-annotations.ts --worktree— confirm all shared-file edits are properly marked.Blocked checks and substitute verification
bun run typecheckfrompackages/opencode/: produces pre-existing errors insrc/cli/cmd/run/footer.ts,src/cli/cmd/run/runtime.lifecycle.ts,src/kilocode/claw/autocomplete.tsx,src/kilocode/cli/cmd/tui/context/tui-config.tsx, etc., all arising from a@opentui/core0.3.2vs0.3.4version skew innode_modules. None of the errors touchpackages/opencode/src/provider/transform.tsor its tests. Substitute verification was targeted typecheck output filtering, which shows zero errors mentioningtransform.ts.Checklist
transform-opus-4.5.test.tsfor 4 providers; existing sharedtransform.test.tsrow updated).changeset/opus-45-enabled-thinking.mdadded)Get in Touch
@TRAVIX26