Skip to content

Instantly share code, notes, and snippets.

@critical
Last active January 14, 2026 23:30
Show Gist options
  • Select an option

  • Save critical/9825c35c5bb87bc32229f0000eef6cf4 to your computer and use it in GitHub Desktop.

Select an option

Save critical/9825c35c5bb87bc32229f0000eef6cf4 to your computer and use it in GitHub Desktop.
OpenCode fix for Anthropic plans
diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts
--- a/packages/opencode/src/session/system.ts
+++ b/packages/opencode/src/session/system.ts
@@ -27,12 +27,12 @@
}
export function provider(model: Provider.Model) {
+ if (model.providerID.includes("anthropic") && model.api.id.includes("claude")) return []
if (model.api.id.includes("gpt-5")) return [PROMPT_CODEX]
if (model.api.id.includes("gpt-") || model.api.id.includes("o1") || model.api.id.includes("o3"))
return [PROMPT_BEAST]
if (model.api.id.includes("gemini-")) return [PROMPT_GEMINI]
- if (model.api.id.includes("claude")) return [PROMPT_ANTHROPIC]
return [PROMPT_ANTHROPIC_WITHOUT_TODO]
}
{ inputs, ... }:
{
environment.systemPackages = [
(inputs.opencode.packages.${pkgs.stdenv.hostPlatform.system}.default.overrideAttrs (old: {
patches =
(old.patches or [])
++ [
./opencode-anthropic-system-prompt.patch
];
}))
];
}
@RGBCube
Copy link

RGBCube commented Jan 9, 2026

awesome

@critical
Copy link
Author

critical commented Jan 9, 2026

Gist updated.

The initial "fix" allowed me to actually interact with the model at least but it ran into issues calling tools. Turns out someone had patched the actual oauth plugin and I just did it that same way since it was merged anyway.

This actually works with tool calls now and is a good temporary fix until the OpenCode releases the official fix.

@maxberggren
Copy link

Lovely! And now you put my eyes on nixOs as well. Tnx!

@anntnzrb
Copy link

anntnzrb commented Jan 9, 2026

... good temporary fix until the OpenCode releases the official fix.

if

@critical
Copy link
Author

I updated this gist for todays block
Patch is based on this PR: anomalyco/opencode#8553

Seems to work so far

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