Skip to content

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
Kilo-Org:mainfrom
rakshith1928:fix/opus-4-5-enabled-thinking
Closed

fix(provider): send enabled thinking for Claude Opus 4.5 across Anthropic, Vertex, Bedrock, and SAP#12548
rakshith1928 wants to merge 6 commits into
Kilo-Org:mainfrom
rakshith1928:fix/opus-4-5-enabled-thinking

Conversation

@rakshith1928

@rakshith1928 rakshith1928 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Issue

Fixes #12546

Context

Why: KiloCode currently sends only the effort parameter 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 require thinking: { type: "enabled", budget_tokens } alongside effort. 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 (after anthropicOmitsThinking):

  • anthropicOpus45(apiId) — matches IDs containing opus-4-5 or opus-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:

  1. Anthropic / Vertex (case "@ai-sdk/anthropic": case "@ai-sdk/google-vertex/anthropic":): replaced the bare { effort } literal branch with a call to anthropicOpus45Effort(model, effort).
  2. Bedrock (case "@ai-sdk/amazon-bedrock":): inserted a new branch before the generic api.id.includes("anthropic") legacy block. Emits { reasoningConfig: { type: "enabled", budgetTokens, maxReasoningEffort: effort } } to match Bedrock's adaptive-branch shape.
  3. SAP AI Core (case "@jerome-benoit/sap-ai-provider-v2":): inserted a new branch before the generic { high, max } fallback. Uses snake_case budget_tokens (SAP's existing convention at that call site) and wraps each variant in modelParams via the existing wrapInSapModelParams helper.

The budget formula Math.min(16_000, Math.floor(model.limit.output / 2 - 1)) is identical to upstream PR #38757's anthropicOpus45Effort. The default mock model in tests has output: 64_000, so budgetTokens saturates to 16000 in regression tests.

Screenshots / Video

N/A — pure backend/provider transform change; no UI diff.

How to Test

Manual/local verification

  • Select Claude Opus 4.5 and verify requests include the required thinking configuration alongside effort.
  • Send a prompt that should trigger extended thinking; observe that thinking summary tokens are now returned and the API request payload contains thinking: { type: "enabled", budget_tokens } alongside effort (Anthropic/Vertex/SAP) or reasoningConfig: { type: "enabled", budgetTokens, maxReasoningEffort } (Bedrock).

Reviewer test steps

  1. 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-20251101 on Anthropic; claude-opus-4-5@default on Vertex; us.anthropic.claude-opus-4-5-20251101-v1:0 on Bedrock; anthropic--claude-opus-4-5-20251101 on SAP).
  2. cd packages/opencode && bun test ./test/provider/transform.test.ts — confirm the existing opus 4.5 row 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.
  3. bun run script/check-opencode-annotations.ts --worktree — confirm all shared-file edits are properly marked.

Blocked checks and substitute verification

  • bun run typecheck from packages/opencode/: produces pre-existing errors in src/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/core 0.3.2 vs 0.3.4 version skew in node_modules. None of the errors touch packages/opencode/src/provider/transform.ts or its tests. Substitute verification was targeted typecheck output filtering, which shows zero errors mentioning transform.ts.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described (new transform-opus-4.5.test.ts for 4 providers; existing shared transform.test.ts row updated)
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes (.changeset/opus-45-enabled-thinking.md added)
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

@TRAVIX26

…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.
@kilo-code-bot

kilo-code-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/opus-45-enabled-thinking.md
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/kilocode/transform-opus-4.5.test.ts
  • packages/opencode/test/provider/transform.test.ts
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)
  • .changeset/opus-45-enabled-thinking.md
  • packages/opencode/src/provider/transform.ts
  • packages/opencode/test/kilocode/transform-opus-4.5.test.ts
  • packages/opencode/test/provider/transform.test.ts

Reviewed by claude-sonnet-5 · Input: 20 · Output: 2.8K · Cached: 394K

Review guidance: REVIEW.md from base branch main

…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.
@johnnyeric
johnnyeric requested a review from chrarnoldus July 27, 2026 11:38
@chrarnoldus chrarnoldus self-assigned this Jul 27, 2026
@chrarnoldus

Copy link
Copy Markdown
Collaborator

thanks, but we'll inherit anomalyco/opencode#38757 when we merge the upstream

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.

[Bug] Claude Opus 4.5 requires legacy thinking payload instead of effort-only

2 participants