Skip to content

Conversation

@ashh-online
Copy link
Contributor

Summary

  • Prefixes tool names with oc_ in outgoing requests
  • Strips the oc_ prefix from tool names in streaming responses

Test plan

Tested with opencode run -m anthropic/claude-sonnet-4-5 and verified tool calls work correctly.

- Prefixes tool names with "oc_" in outgoing requests
- Strips the "oc_" prefix from tool names in streaming responses

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@devxoul
Copy link

devxoul commented Jan 9, 2026

I can confirm this works

@junhoyeo
Copy link

junhoyeo commented Jan 9, 2026

if it works i think we can propose a more general solution like obfuscating tool names on each request/session etc

@devxoul
Copy link

devxoul commented Jan 9, 2026

Here's how to run this patch locally:

(since anomalyco/opencode#5957 isn't merged yet, we cannot override built-in plugins so we need to built both opencode and the anthropic plugin to test)

Updated (After 0.0.7 got released)

Just add opencode-anthropic-auth@0.0.7 to the plugins field in you opencode.json.

(@0.0.7 isn't required actually but I prefer specifying them because OpenCode will always check for the latest version via npm which slows down the startup when version is not specified)

Archived

1. Plugin: Clone and Checkout the PR Branch

git clone https://github.com/anomalyco/opencode-anthropic-auth.git  # if not already cloned
cd opencode-anthropic-auth
gh pr checkout 10  # or: git fetch origin fix/claude-oauth-tools && git checkout fix/claude-oauth-tools
bun install

2. OpenCode: Modify opencode to Use Local Plugin

In packages/opencode/src/plugin/index.ts, change the BUILTIN array:

- const BUILTIN = ["opencode-copilot-auth@0.0.9", "opencode-anthropic-auth@0.0.5"]
+ const BUILTIN = ["opencode-copilot-auth@0.0.9", "file:///path/to/opencode-anthropic-auth/index.mjs"]

3. Run opencode

cd /path/to/opencode
bun install
bun dev

4. To Run Globally

cd packages/opencode && bun run build -- --single
export PATH=$PWD/dist/opencode-darwin-arm64/bin/:$PATH

@KimDaehyeon6873
Copy link

So, after this, there will be no issue about "This credential is only authorized for use with Claude Code and cannot be used for other API requests."?

@jksjaz
Copy link

jksjaz commented Jan 9, 2026

Claude bypass written by claude 🤣

@tariqkb
Copy link

tariqkb commented Jan 9, 2026

FWIW, renaming the tools to match claude code's tools exactly also fixes it. i.e. use PascalCase for tool names

@rdvo
Copy link

rdvo commented Jan 9, 2026

what are the actual tool names in CC? I feel matching them would be better than a prefix that cna easily blcok again

@zainsyedz
Copy link

FWIW, renaming the tools to match claude code's tools exactly also fixes it. i.e. use PascalCase for tool names

So they're creating a signature at their end to verify the client?

@airtonix
Copy link

airtonix commented Jan 9, 2026

what are the actual tool names in CC? I feel matching them would be better than a prefix that cna easily blcok again

anomalyco/opencode#7410 (comment)

It's mostly: {name}_tool

@rekram1-node rekram1-node merged commit 9871607 into anomalyco:master Jan 9, 2026
@zkdiff
Copy link

zkdiff commented Jan 9, 2026

Legendary!

@qlido
Copy link

qlido commented Jan 9, 2026

@lastbattle
Copy link

wow thats fast

@Sewer56
Copy link

Sewer56 commented Jan 9, 2026

This would still be easy to catch server side.
Should we not just rename the tools to capitalize the first letter?
That way, they would match CC's.

@rekram1-node

[Well, that only works till the lawyers get involved, but still]

@JimiHFord
Copy link

Issues with Claude Opus and Oh My Opencode sent me here. Now that it's merged, anyone know how we can test it out with oh my opencode? Pretty new to how all this stuff is connected tbh

@ChaseRensberger
Copy link

if this was the best they could come up with to stop third party users then i think we are safe for a while

@gtg7784
Copy link

gtg7784 commented Jan 9, 2026

Here's how to run this patch locally:

(since anomalyco/opencode#5957 isn't merged yet, we cannot override built-in plugins so we need to built both opencode and the anthropic plugin to test)

1. Plugin: Clone and Checkout the PR Branch

git clone https://github.com/anomalyco/opencode-anthropic-auth.git  # if not already cloned
cd opencode-anthropic-auth
gh pr checkout 10  # or: git fetch origin fix/claude-oauth-tools && git checkout fix/claude-oauth-tools
bun install

2. OpenCode: Modify opencode to Use Local Plugin

In packages/opencode/src/plugin/index.ts, change the BUILTIN array:

- const BUILTIN = ["opencode-copilot-auth@0.0.9", "opencode-anthropic-auth@0.0.5"]
+ const BUILTIN = ["opencode-copilot-auth@0.0.9", "file:///path/to/opencode-anthropic-auth/index.mjs"]

3. Run opencode

cd /path/to/opencode
bun install
bun dev

4. To Run Globally

cd packages/opencode && bun run build -- --single
export PATH=$PWD/dist/opencode-darwin-arm64/bin/:$PATH

@devxoul you saved my life, thanks

@harshav167
Copy link
Contributor

Re: #10 (comment) — you can override the plugin via config now (no core source edits needed):\n\n\n\nThis loads the local plugin without modifying opencode source.

@dominicnieto
Copy link

Re: #10 (comment) — you can override the plugin via config now (no core source edits needed):\n\n\n\nThis loads the local plugin without modifying opencode source.

how do i do this?

@adiman9
Copy link

adiman9 commented Jan 9, 2026

Re: #10 (comment) — you can override the plugin via config now (no core source edits needed):\n\n\n\nThis loads the local plugin without modifying opencode source.

how do i do this?

Just add "opencode-anthropic-auth" into the plugin array in opencode.json

@devxoul
Copy link

devxoul commented Jan 9, 2026

Re: #10 (comment) — you can override the plugin via config now (no core source edits needed):\n\n\n\nThis loads the local plugin without modifying opencode source.

how do i do this?

Just add "opencode-anthropic-auth" into the plugin array in opencode.json

Oh yeah, 0.0.7 has released recently so that would work now. Now I can update the workaround. 👉 updated

@MickBuilder
Copy link

Here's how to run this patch locally:

(since anomalyco/opencode#5957 isn't merged yet, we cannot override built-in plugins so we need to built both opencode and the anthropic plugin to test)

Updated (After 0.0.7 got released)

Just add opencode-anthropic-auth@0.0.7 to the plugins field in you opencode.json.

(@0.0.7 isn't required actually but I prefer specifying them because OpenCode will always check for the latest version via npm which slows down the startup when version is not specified)

Archived

1. Plugin: Clone and Checkout the PR Branch

git clone https://github.com/anomalyco/opencode-anthropic-auth.git  # if not already cloned
cd opencode-anthropic-auth
gh pr checkout 10  # or: git fetch origin fix/claude-oauth-tools && git checkout fix/claude-oauth-tools
bun install

2. OpenCode: Modify opencode to Use Local Plugin

In packages/opencode/src/plugin/index.ts, change the BUILTIN array:

- const BUILTIN = ["opencode-copilot-auth@0.0.9", "opencode-anthropic-auth@0.0.5"]
+ const BUILTIN = ["opencode-copilot-auth@0.0.9", "file:///path/to/opencode-anthropic-auth/index.mjs"]

3. Run opencode

cd /path/to/opencode
bun install
bun dev

4. To Run Globally

cd packages/opencode && bun run build -- --single
export PATH=$PWD/dist/opencode-darwin-arm64/bin/:$PATH

I'm not finding "opencode.json" but "package.json"

@stevechoi0222
Copy link

please update in here if someone gets banned using this method

fernando234234 added a commit to fernando234234/Roo-Code that referenced this pull request Jan 9, 2026
Fixes Claude Code OAuth token authentication issues by aligning the
request shape with what Anthropic's API expects for OAuth tokens.

Changes:
- Update User-Agent to match Claude CLI format: "claude-cli/VERSION (external, cli)"
- Remove fine-grained-tool-streaming beta header (incompatible with OAuth)
- Add tool name prefixing with "oc_" prefix to bypass tool validation
- Strip prefix from tool names in responses for internal consistency
- Prefix tool names in conversation history to match tool definitions

The tool name prefixing is necessary because Anthropic's API validates
tool names against a known list when using OAuth tokens. By prefixing
with "oc_" we can use custom tool names while maintaining compatibility.

Inspired by fixes from:
- anomalyco/opencode-anthropic-auth#10
- anomalyco/opencode-anthropic-auth#11

Thanks to @anomalyco for the original research and implementation.
@devxoul
Copy link

devxoul commented Jan 9, 2026

I'm not finding "opencode.json" but "package.json"

@MickBuilder Check your config file locations.

@JulianMason
Copy link

does this actually work? I implemented it and oauth works, however, i can only use Sonnet. Even though I see full list of Anthropic models I can use, no matter which I select (like Opus 4.5), when I asked the model which model it is, it says Sonnet. I ask the same question on Claude Code after selecting Opus 4.5 and the output is Opus 4.5. Anyone else experiencing this?

@hiddentn
Copy link

hiddentn commented Jan 9, 2026

Is anyone else experiencing this again? (2:30 PM Friday, Jan 9, 2026 UTC)

@fivetaku
Copy link

fivetaku commented Jan 9, 2026

It worked great for me at first, but my Claude Code OAuth access seems to be blocked again now.

@aciceri
Copy link

aciceri commented Jan 9, 2026

It worked great for me at first, but my Claude Code OAuth access seems to be blocked again now.

Same here

@HaD0Yun
Copy link

HaD0Yun commented Jan 9, 2026

Some guy solve that problem do this

https://github.com/fivetaku/opencode-oauth-fix

roomote bot pushed a commit to RooCodeInc/Roo-Code that referenced this pull request Jan 11, 2026
Fixes Claude Code OAuth token authentication issues by aligning the
request shape with what Anthropic's API expects for OAuth tokens.

Changes:
- Update User-Agent to match Claude CLI format: "claude-cli/VERSION (external, cli)"
- Remove fine-grained-tool-streaming beta header (incompatible with OAuth)
- Add tool name prefixing with "oc_" prefix to bypass tool validation
- Strip prefix from tool names in responses for internal consistency
- Prefix tool names in conversation history to match tool definitions

The tool name prefixing is necessary because Anthropic's API validates
tool names against a known list when using OAuth tokens. By prefixing
with "oc_" we can use custom tool names while maintaining compatibility.

Inspired by fixes from:
- anomalyco/opencode-anthropic-auth#10
- anomalyco/opencode-anthropic-auth#11

Thanks to @anomalyco for the original research and implementation.
@guisaliba
Copy link

does it still work?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.