Skip to content

fix(copilot): correct Claude thinking variants and context windows#20319

Closed
MoonFuji wants to merge 2 commits intoanomalyco:devfrom
MoonFuji:fix/copilot-claude-variants-context
Closed

fix(copilot): correct Claude thinking variants and context windows#20319
MoonFuji wants to merge 2 commits intoanomalyco:devfrom
MoonFuji:fix/copilot-claude-variants-context

Conversation

@MoonFuji
Copy link
Copy Markdown

Summary

Two bugs fixed for Claude models served via GitHub Copilot:

1. Multi-level thinking budget variants (transform.ts)

Before: Only a single binary thinking variant with a hardcoded 4,000-token budget.

After: Four granular budget levels matching standard tiers:

Variant thinking_budget
low 1,000 tokens
medium 4,000 tokens
high 10,000 tokens
max 16,000 tokens

Uses the Copilot SDK flat snake_case format (thinking_budget: number) as defined in openai-compatible-chat-options.ts — not the @ai-sdk/anthropic format.

2. Correct context windows (provider.ts)

Before: Context windows sourced from models.dev which contains stale/incorrect values (e.g. claude-opus-4.6 shown as ~128K).

After: Override table applied when m.api.npm === "@ai-sdk/github-copilot", based on official Anthropic documentation:

Model Correct context
claude-opus-4.6, claude-sonnet-4.6 1,000,000 tokens
claude-opus-4.5, claude-sonnet-4.5, claude-haiku-4.5 200,000 tokens

Both dot-notation (4.6) and dash-notation (4-6) IDs are handled to cover API naming variations.

Files changed

  • packages/opencode/src/provider/transform.ts
  • packages/opencode/src/provider/provider.ts

Previously, GitHub Copilot Claude models had only a single binary "thinking"
variant with a fixed 4000 token budget. This adds four granular levels matching
typical budget tiers used across other providers:

- low:    1,000 tokens
- medium: 4,000 tokens
- high:   10,000 tokens
- max:    16,000 tokens

Uses the Copilot SDK flat snake_case format (thinking_budget: number) as
confirmed in openai-compatible-chat-options.ts.
models.dev reports stale/incorrect context windows for Anthropic Claude models
served via GitHub Copilot. This adds an override table based on official
Anthropic documentation (https://docs.anthropic.com/en/docs/about-claude/models):

  claude-opus-4.6   / claude-sonnet-4.6  → 1,000,000 tokens
  claude-opus-4.5   / claude-sonnet-4.5  → 200,000 tokens
  claude-haiku-4.5                       → 200,000 tokens

Both dot-notation (4.6) and dash-notation (4-6) IDs are handled to cover any
naming variations returned by the Copilot API.
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 31, 2026
@github-actions
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.

@github-actions
Copy link
Copy Markdown
Contributor

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

Based on the search results, I found two highly related PRs that may be duplicates or overlapping with PR #20319:

Related PRs:

  1. PR fix(opencode): correct GitHub Copilot Claude context limits and thinking variants #20318 - "fix(opencode): correct GitHub Copilot Claude context limits and thinking variants"

  2. PR fix(provider): add thinking level variants for GitHub Copilot Claude models #15167 - "fix(provider): add thinking level variants for GitHub Copilot Claude models"

  3. PR fix(provider): convert thinking.budgetTokens to snake_case for openai-compatible SDK #12544 - "fix(provider): convert thinking.budgetTokens to snake_case for openai-compatible SDK"

  4. PR feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 #12342 - "feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6"

Most critical: Check PR #20318 first - it appears to be the closest duplicate addressing the same fixes.

@rekram1-node
Copy link
Copy Markdown
Collaborator

U cant just override the context windows, these arent going to be accurate for most copilot users.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 31, 2026
@github-actions github-actions bot closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants