GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 by okhsunrog · Pull Request #12342 · anomalyco/opencode

Conversation

@okhsunrog

@okhsunrog okhsunrog commented Feb 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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: anomalyco/models.dev#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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yaasin-raki2, angristan, sjawhar, tredondo, jvdmeulen92, Akramz, shakedlokits, stephenh, 381181295, linkvt, and againxx reacted with thumbs up emoji angristan, Akramz, and muzzwood reacted with hooray emoji Under-Lion, disrupted, Daniel-Boll, Dsyt123, omerdn1, qqrm, TemaSM, angristan, ErcinDedeoglu, ruslan-kurchenko, and 28 more reacted with heart emoji angristan, DusKing1, Akramz, and muzzwood reacted with rocket emoji angristan and dottharun reacted with eyes emoji
All reactions
  • 👍 11 reactions
  • 🎉 3 reactions
  • ❤️ 38 reactions
  • 🚀 4 reactions
  • 👀 2 reactions
@github-actions github-actions Bot added the needs:issue label Feb 5, 2026
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Feb 5, 2026
@okhsunrog
okhsunrog force-pushed the feat/opus-4-6-adaptive-thinking branch from 7ffe6a8 to a3ebbc5 Compare February 5, 2026 20:58
@okhsunrog
okhsunrog marked this pull request as draft February 5, 2026 21:00
@okhsunrog

okhsunrog commented Feb 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Adding of adaptive thinking needs an upgrade of @ai-sdk/anthropic which leads to upgrading of a bunch of other packages. Making it a draft for now.
I started working on upgrading the deps, I hope it can be made as part of this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog
okhsunrog force-pushed the feat/opus-4-6-adaptive-thinking branch from a3ebbc5 to 5316c7e Compare February 5, 2026 21:38
@okhsunrog
okhsunrog marked this pull request as ready for review February 5, 2026 21:45
@okhsunrog

okhsunrog commented Feb 5, 2026

Copy link
Copy Markdown
Author

Added a commit with dependencies upgrade. Tested locally, switching effort levels with Opus 4.6 now works as expected

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog okhsunrog mentioned this pull request Feb 5, 2026
1M tokens for Opus 4.6 #12338
Closed
@okhsunrog

okhsunrog commented Feb 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Can anyone test if 1M context for you? It works for me just fine with Opus 4.6. I managed to get up to 340k token

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ItsWendell

ItsWendell commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

@okhsunrog what's the easiest way to test this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog

okhsunrog commented Feb 5, 2026

Copy link
Copy Markdown
Author

@ItsWendell make sure you have latest bun installed, then run these commands:

git clone -b feat/opus-4-6-adaptive-thinking https://github.com/okhsunrog/opencode.git
cd opencode
bun install
bun dev
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ItsWendell

ItsWendell commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Tested and works:
image
image

okhsunrog reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ItsWendell

ItsWendell commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Couple of issues that I ran into, at e.g. 400 tokens I again get a error:

image image
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog

okhsunrog commented Feb 6, 2026

Copy link
Copy Markdown
Author
image image well, shit...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog

okhsunrog commented Feb 6, 2026

Copy link
Copy Markdown
Author

@ItsWendell yes, I confirm the issue is there. but if we'd pass context-1m-2025-08-07 header we'd get error from Anthropic with OAuth, that the long context beta is not available for this subscription. Are you using it with Claude subscription via OAuth or vie Anthropic API?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog

okhsunrog commented Feb 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

Confirmed, the 200k limit is enforced by the Anthropic API. The status bar shows a combined total (input + output + cache tokens), but the API only counts input tokens against the 200k limit. That's why I didn't hit it earlier — actual input tokens stayed under 200k even though the status bar showed 385k.
The context-1m-2025-08-07 beta header is needed for Opus 4.6 to go past 200k, same as Sonnet 4/4.5. The compaction check in opencode uses this combined count:

// compaction.ts:35
const count = input.tokens.input + input.tokens.cache.read + input.tokens.output

So opencode thinks there's plenty of headroom (39% of 1M) while the API is already at the 200k input limit. I'll update my PR to add the context-1m-2025-08-07 beta header for non-OAuth.

P.S. Worth noting that the 200k limit on Opus 4.6 without the beta header is different from the 200k context window on models like Haiku 4.5. For Haiku 4.5, 200k is the total context window — input tokens, output tokens, everything has to fit within that 200k budget. For Opus 4.6, the context window is actually 1M — the 200k is only a gate on input tokens. Output and thinking tokens live in the larger 1M space and don't count against the 200k. So even without the context-1m-2025-08-07 header, Opus 4.6 gives you significantly more effective room. For example, if you're using extended thinking with large thinking budgets, those tokens aren't eating into your 200k input limit like they would eat into Haiku 4.5's 200k context window. And thinking tokens from previous turns are automatically stripped by the API, so they don't accumulate as input at all.

ItsWendell, Under-Lion, theniceboy, TemaSM, rdvo, motonari728, and againxx reacted with rocket emoji
All reactions
  • 🚀 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog okhsunrog mentioned this pull request Feb 6, 2026
fix(opencode): add input token limit for Claude Opus 4.6 anomalyco/models.dev#819
Closed
okhsunrog added 2 commits February 6, 2026 04:19
@okhsunrog
feat(provider): add adaptive thinking support for Claude Opus 4.6
3332697
- 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.

Ref: https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking
@okhsunrog
feat(provider): upgrade AI SDK to v6 for Opus 4.6 adaptive thinking
0e3dbb6
- Upgrade ai package from 5.0.124 to 6.0.72
- Upgrade @ai-sdk/anthropic from 2.0.58 to 3.0.37 (adds adaptive thinking support)
- Upgrade all @ai-sdk/* packages to v3+/v4+ for compatibility
- Update LanguageModelV2 to LanguageModelV3 across codebase
- Make toModelMessages async per AI SDK 6 requirements
- Update toModelOutput signature to use destructured parameter
- Fix tool factory renames and remove deprecated name property
- Update tests for new LanguageModelUsage type structure

Enables Claude Opus 4.6 to use adaptive thinking with effort levels
(low/medium/high/max) instead of fixed budget tokens.
This was referenced Feb 6, 2026
[backend] Port 1M context / adaptive thinking for Opus 4.6 (upstream #12338) randomm/opencode#150
Closed
feat(opencode): enable 1M context + adaptive thinking for Opus 4.6 (#150) randomm/opencode#152
Merged
[critical] Opus still limited to 200k tokens despite context-1m header randomm/opencode#154
Closed
@okhsunrog

okhsunrog commented Feb 6, 2026

Copy link
Copy Markdown
Author

@rekram1-node @thdxr could anyone review this, please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog
okhsunrog force-pushed the feat/opus-4-6-adaptive-thinking branch from cd15179 to b49a992 Compare February 6, 2026 08:39
@randomm randomm mentioned this pull request Feb 6, 2026
[strategy] Fork maintenance strategy - decouple, contribute, minimize randomm/opencode#157
Closed
6 tasks
@okhsunrog okhsunrog changed the title feat(provider): add adaptive thinking support for Claude Opus 4.6 feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 Feb 6, 2026
@ruslan-kurchenko ruslan-kurchenko mentioned this pull request Feb 6, 2026
feat(zen): enable 1M context window for Opus 4.6 and Sonnet 4.5 #12451
Closed
@reynard93

reynard93 commented Feb 6, 2026

Copy link
Copy Markdown

how did anyone manage to use with this branch? i keep getting : The long context beta is not yet available for this subscription

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@okhsunrog
feat(provider): add 1M context beta header, fix SDK v6 token double-c…
471746d
…ounting, use plugin fork for OAuth context cap
@okhsunrog
okhsunrog force-pushed the feat/opus-4-6-adaptive-thinking branch from b49a992 to 471746d Compare February 6, 2026 17:14
@BouquetAntoine BouquetAntoine mentioned this pull request Feb 6, 2026
Support adaptive thinking for Claude Opus 4.6 #12485
Closed
avarayr
avarayr reviewed Feb 6, 2026
View reviewed changes
Comment thread packages/opencode/src/plugin/index.ts
@@ -16,15 +16,14 @@ import { gitlabAuthPlugin as GitlabAuthPlugin } from "@gitlab/opencode-gitlab-au
export namespace Plugin {
const log = Log.create({ service: "plugin" })

const BUILTIN = ["opencode-anthropic-auth@0.0.13"]
const BUILTIN = ["github:okhsunrog/opencode-anthropic-auth#feat/oauth-context-cap"]

@avarayr avarayr Feb 6, 2026

Copy link
Copy Markdown

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.

opencode core shouldn't have builtin plugins that pull from forks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rekram1-node rekram1-node Feb 6, 2026

Copy link
Copy Markdown
Member

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.

correct

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@okhsunrog okhsunrog Feb 6, 2026

Copy link
Copy Markdown
Author

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.

It was only supposed for testing till changes to opencode-anthropoc-auth are accepted

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BouquetAntoine

BouquetAntoine commented Feb 11, 2026

Copy link
Copy Markdown

Hi, anything new here ? I'm using this branch (with official opencode anthropic auth) and it works perfectly (Azure Anthropic & Anthropic API) untested with claude code.

Double tokens counting is fixed 👌
1M supports is OK (with beta header in Opencode config), adaptative thinking seems fine, with effort parameter 👌

Opus 4.6 is inusable with custom config without this PR 😅 (usable with Zen, Openrouter, Cloudflare Gateway, ... but any advanced config is ignored)

@rekram1-node @avarayr

nil0ft, angristan, cascadingstyletrees, acacuce, and DusKing1 reacted with thumbs up emoji
All reactions
  • 👍 5 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Feb 11, 2026
fix(provider): split Bedrock Opus 4.6 into 200K and 1M variants #13200
Closed
feat: bump AI SDK to v6 + add Opus 4.6 adaptive thinking #13228
Closed
@cascadingstyletrees cascadingstyletrees mentioned this pull request Feb 12, 2026
[FEATURE]: Add Claude Opus 4.6 adaptive thinking support #13227
Closed
1 task done
@github-actions github-actions Bot mentioned this pull request Feb 13, 2026
feat: enable 1M context window for Anthropic Claude models #13457
Closed
@smashah

smashah commented Feb 14, 2026

Copy link
Copy Markdown

Is there a plugin or something i can install in the meantime to fix this error?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BouquetAntoine

BouquetAntoine commented Feb 14, 2026

Copy link
Copy Markdown

Is there a plugin or something i can install in the meantime to fix this error?

can't be fixed with a plugin, you need to fork last version of opencode, then merge this branch into your fork (and resolve merge conflicts, if any), then build it and use the new binary until opencode team merge this PR
(or just use this branch but it wouldn't have last opencode changes)

Note : I had to revert this change :

  • const BUILTIN = ["[email protected]"]
    +const BUILTIN = ["github:okhsunrog/opencode-anthropic-auth#feat/oauth-context-cap"]

Working well with API, don't know if it will works well with Claude Code.
You might need some adjustements but all of this can be done by Opencode/Claude Code itself

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cemo cemo mentioned this pull request Feb 15, 2026
[Bug]: Context window limit hardcoded to 200K — ignores Claude Opus 4.6 native 1M support unless env var is set code-yeongyu/oh-my-openagent#1753
Closed
@github-actions github-actions Bot mentioned this pull request Feb 19, 2026
feat(opencode): support adaptive thinking for claude sonnet 4.6 #14283
Merged
3 of 6 tasks
@DusKing1 DusKing1 mentioned this pull request Feb 20, 2026
feat(provider): add 1M context window support for Anthropic models #14375
Closed
4 of 6 tasks
This was referenced Mar 2, 2026
feat(provider): graceful context-1m fallback for sub-Tier-4 accounts #15641
Closed
feat(gitlab): send context-1m-2025-08-07 beta header to enable 1M context window #16153
Merged
@altendky altendky mentioned this pull request Mar 10, 2026
fix(provider): skip empty-text filtering for assistant messages in normalizeMessages (#16748) #16750
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Mar 11, 2026
fix(provider): resolve bedrock compaction failures for Claude models #17043
Closed
@cyberprophet cyberprophet mentioned this pull request Mar 17, 2026
bug: OAuth auth + cache_control ephemeral causes HTTP 400 on all Claude models since 2026-03-17 #17910
Closed
@davetha davetha mentioned this pull request Mar 19, 2026
"Extra usage is required for long context requests" error still occurs after Anthropic removed long-context premium (March 13) #18242
Closed
This was referenced Mar 29, 2026
add Claude Opus 4.6 (1M context) to GitHub Copilot provider #19842
Closed
fix(copilot): correct Claude thinking variants and context windows #20319
Closed
update beta header for github copilot claude opus 4.6 to support 1m context #20498
Closed
@github-actions github-actions Bot mentioned this pull request Apr 15, 2026
fix: guard Anthropic thinking budgetTokens for unknown output limits #22581
Closed
3 tasks done
@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

angristan and erwan reacted with thumbs down emoji
All reactions
  • 👎 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Apr 16, 2026
@erwan

erwan commented Apr 16, 2026

Copy link
Copy Markdown

should that be reopened? This is the only thing I'm missing to completely switch away from Claude Code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BouquetAntoine

BouquetAntoine commented Apr 16, 2026

Copy link
Copy Markdown

should that be reopened? This is the only thing I'm missing to completely switch away from Claude Code.

should be working now as they updated ai-sdk, you might need to edit your provider configuration depending on your anthropic provider & available options at your account level

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rekram1-node rekram1-node rekram1-node left review comments
+1 more reviewer
@avarayr avarayr avarayr left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Claude Opus 4.6 context window limits still 200k 1M tokens for Opus 4.6 [FEATURE]: Add support of Claude Opus 4.6

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@okhsunrog @ItsWendell @BouquetAntoine @reynard93 @smashah @erwan @avarayr @rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.