Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

fix(provider): scope Anthropic context-1m beta header to 1M models#605

Closed
Olusammytee wants to merge 1 commit intoKilo-Org:devfrom
Olusammytee:fix/482-anthropic-context-header
Closed

fix(provider): scope Anthropic context-1m beta header to 1M models#605
Olusammytee wants to merge 1 commit intoKilo-Org:devfrom
Olusammytee:fix/482-anthropic-context-header

Conversation

@Olusammytee
Copy link
Copy Markdown

Summary

  • remove unconditional context-1m-2025-08-07 beta from default Anthropic headers
  • add model-aware loader logic that only re-adds the 1M beta for Anthropic model IDs containing 1m
  • keep all other Anthropic beta headers intact to preserve existing behavior

Fixes Kilo-Org/kilocode#6300

@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.

}

headers["anthropic-beta"] = parts.join(",")
const sdk = createAnthropic({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: This creates a brand-new createAnthropic() SDK using only the raw provider.options, discarding the pre-built sdk parameter (renamed _sdk on line 110). Every other getModel implementation in this file (openai, github-copilot, azure, amazon-bedrock, etc.) uses the passed sdk parameter.

The sdk passed to getModel is built by getSDK() which enriches provider.options with apiKey, baseURL, model-specific headers, and a custom fetch wrapper (with timeout logic, OpenAI ID stripping, etc.). By creating a new SDK here, all of those are lost.

This means Anthropic 1M-context models will likely fail or behave incorrectly because the new SDK won't have the API key, base URL, or timeout handling.

Consider modifying the headers on the existing sdk or restructuring so the beta header is applied at the getSDK level based on the model ID, rather than creating a separate SDK instance.

.filter(Boolean)
.filter((item) => item !== longContextBeta)

if (modelID.toLowerCase().includes("1m")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The check modelID.toLowerCase().includes("1m") is fragile. It would match any model ID containing "1m" anywhere (e.g., a hypothetical model like claude-21march or claude-v1mini). Consider a more specific pattern like checking for -1m- or a suffix match to reduce false positives.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 22, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/opencode/src/provider/provider.ts 125 New createAnthropic() SDK discards the pre-built sdk (with apiKey, baseURL, fetch wrapper, timeout). Anthropic 1M-context models will likely fail or lose timeout/auth handling.

WARNING

File Line Issue
packages/opencode/src/provider/provider.ts 120 modelID.toLowerCase().includes("1m") is a fragile check that could match unintended model IDs
Files Reviewed (1 files)
  • packages/opencode/src/provider/provider.ts - 2 issues

Fix these issues in Kilo Cloud

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the context-1m-2025-08-07 Anthropic beta header was being sent unconditionally for all Anthropic API requests, causing errors for users on plans without long context access (like Claude Max plan) when using standard 200K context models.

Changes:

  • Removed context-1m-2025-08-07 from the default Anthropic beta headers
  • Added a custom getModel() function that conditionally includes the 1M context beta header only for models with "1m" in their ID
  • Preserved all other Anthropic beta headers (claude-code, interleaved-thinking, fine-grained-tool-streaming)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@markijbema markijbema closed this Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants