Skip to content

Commit 65eedde

Browse files
committed
fix(opencode): correct GitHub Copilot Claude context limits and thinking variants
- provider.ts: override models.dev incorrect context/output limits for GitHub Copilot Claude models in fromModelsDevModel(). models.dev reports wrong values (e.g. claude-opus-4.6 as 144k context) vs Anthropic docs. - transform.ts: fix @ai-sdk/github-copilot claude branch in variants() to return adaptive effort levels (low/medium/high/max for opus-4.6 and sonnet-4.6; high/max for other claude models) instead of a single hardcoded 'thinking' variant. Fixes anomalyco#20317
1 parent 434d82b commit 65eedde

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

‎packages/opencode/src/provider/provider.ts‎

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,35 @@ export namespace Provider {
915915
}
916916
: undefined,
917917
},
918-
limit: {
919-
context: model.limit.context,
920-
input: model.limit.input,
921-
output: model.limit.output,
922-
},
918+
limit: iife(() => {
919+
// models.dev has incorrect context/output limits for GitHub Copilot Claude models.
920+
// Override with the correct values from Anthropic's official documentation.
921+
// See: https://platform.claude.com/docs/en/about-claude/models/overview
922+
if (provider.id === "github-copilot" && model.id.includes("claude")) {
923+
const COPILOT_CLAUDE_LIMITS: Record<string, { context: number; output: number }> = {
924+
"claude-opus-4.6": { context: 1_000_000, output: 128_000 },
925+
"claude-sonnet-4.6": { context: 1_000_000, output: 64_000 },
926+
"claude-haiku-4.5": { context: 200_000, output: 64_000 },
927+
"claude-opus-4.5": { context: 200_000, output: 32_000 },
928+
"claude-sonnet-4.5": { context: 200_000, output: 64_000 },
929+
"claude-sonnet-4": { context: 200_000, output: 16_000 },
930+
"claude-opus-41": { context: 200_000, output: 32_000 },
931+
}
932+
const override = COPILOT_CLAUDE_LIMITS[model.id]
933+
if (override) {
934+
return {
935+
context: override.context,
936+
input: model.limit.input,
937+
output: override.output,
938+
}
939+
}
940+
}
941+
return {
942+
context: model.limit.context,
943+
input: model.limit.input,
944+
output: model.limit.output,
945+
}
946+
}),
923947
capabilities: {
924948
temperature: model.temperature,
925949
reasoning: model.reasoning,

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,17 @@ export namespace ProviderTransform {
464464
return {}
465465
}
466466
if (model.id.includes("claude")) {
467+
if (isAnthropicAdaptive) {
468+
return {
469+
low: { thinking_budget: 1024 },
470+
medium: { thinking_budget: 8000 },
471+
high: { thinking_budget: 16000 },
472+
max: { thinking_budget: 31999 },
473+
}
474+
}
467475
return {
468-
thinking: { thinking_budget: 4000 },
476+
high: { thinking_budget: 8000 },
477+
max: { thinking_budget: 16000 },
469478
}
470479
}
471480
const copilotEfforts = iife(() => {

0 commit comments

Comments
 (0)