Skip to content

Commit da1efda

Browse files
committed
fix(opencode): fix 1M context for Opus - compaction token counting (#154)
- Fix compaction to count only input tokens (not output/thinking) - Add /upstream-gap custom command
1 parent 5d06efb commit da1efda

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎packages/opencode/src/plugin/copilot.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
305305
if (!input.model.providerID.includes("github-copilot")) return
306306

307307
if (input.model.api.npm === "@ai-sdk/anthropic") {
308-
output.headers["anthropic-beta"] = "interleaved-thinking-2025-05-14"
308+
output.headers["anthropic-beta"] =
309+
"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07"
309310
}
310311

311312
const session = await sdk.session

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export namespace Provider {
7373
options: {
7474
headers: {
7575
"anthropic-beta":
76-
"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,adaptive-thinking-2026-01-28,context-1m-2025-08-07",
76+
"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07",
7777
},
7878
},
7979
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,15 @@ export namespace ProviderTransform {
456456
modelId.includes("claude-opus-4.6")
457457

458458
if (isOpus46) {
459-
// Opus 4.6 uses adaptive thinking with effort levels
459+
// Opus 4.6 uses GA 'effort' parameter (no beta header required, officially recommended by Anthropic)
460+
// Note: thinking type: 'adaptive' is separate and requires adaptive-thinking beta header
460461
return {
462+
low: {
463+
thinking: {
464+
type: "enabled",
465+
effort: "low",
466+
},
467+
},
461468
high: {
462469
thinking: {
463470
type: "enabled",

0 commit comments

Comments
 (0)