[PR #12342] feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 #14178

Open
opened 2026-02-16 18:18:59 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12342

State: open
Merged: No


Adaptive thinking

  • Add adaptive-thinking-2026-01-28 beta header for Anthropic provider
  • Detect Opus 4.6 models and use adaptive thinking with effort parameter
  • Support all effort levels: low, medium, high, max
  • Older models continue to use manual thinking with budgetTokens

Opus 4.6 uses adaptive thinking where the model decides how much to think based on task complexity, guided by the effort parameter. This is more efficient than fixed budgetTokens as simple tasks use minimal thinking.

1M context window

  • Add context-1m-2025-08-07 beta header for Anthropic provider (API key users)
  • Fix compaction logic: when model.limit.input is set, compare input tokens only against that limit instead of the combined total (input + cache + output)

Without the beta header, Opus 4.6 enforces a 200k input token limit (the context window is still 1M — output/thinking tokens aren't affected). The opencode (OAuth) provider doesn't support the 1M beta header, so it relies on model.limit.input in models.dev to trigger compaction at the right time: https://github.com/anomalyco/models.dev/pull/819

AI SDK upgrade

  • Upgrade ai v5 → v6, @ai-sdk/anthropic v2 → v3, and all @ai-sdk/* packages
  • Migrate LanguageModelV2LanguageModelV3, async toModelMessages, renamed tool factories

Ref: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking
Ref: https://platform.claude.com/docs/en/build-with-claude/context-windows#1-m-token-context-window

Tested locally, works with Opus 4.6

Closes #12323
Closes #12338
Closes #12438

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12342 **State:** open **Merged:** No --- ## Adaptive thinking - Add `adaptive-thinking-2026-01-28` beta header for Anthropic provider - Detect Opus 4.6 models and use adaptive thinking with effort parameter - Support all effort levels: low, medium, high, max - Older models continue to use manual thinking with budgetTokens Opus 4.6 uses adaptive thinking where the model decides how much to think based on task complexity, guided by the effort parameter. This is more efficient than fixed budgetTokens as simple tasks use minimal thinking. ## 1M context window - Add `context-1m-2025-08-07` beta header for Anthropic provider (API key users) - Fix compaction logic: when `model.limit.input` is set, compare input tokens only against that limit instead of the combined total (input + cache + output) Without the beta header, Opus 4.6 enforces a 200k input token limit (the context window is still 1M — output/thinking tokens aren't affected). The `opencode` (OAuth) provider doesn't support the 1M beta header, so it relies on `model.limit.input` in models.dev to trigger compaction at the right time: https://github.com/anomalyco/models.dev/pull/819 ## AI SDK upgrade - Upgrade `ai` v5 → v6, `@ai-sdk/anthropic` v2 → v3, and all `@ai-sdk/*` packages - Migrate `LanguageModelV2` → `LanguageModelV3`, async `toModelMessages`, renamed tool factories Ref: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking Ref: https://platform.claude.com/docs/en/build-with-claude/context-windows#1-m-token-context-window Tested locally, works with Opus 4.6 Closes #12323 Closes #12338 Closes #12438
yindo added the pull-request label 2026-02-16 18:18:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14178