-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(claude-code): OAuth compatibility and tool name validation #10570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(claude-code): OAuth compatibility and tool name validation #10570
Conversation
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.
Reviewed latest commit (6746b3e). The reasoning text duplication fix looks correct. Previous test issues remain unresolved.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| "oauth-2025-04-20", | ||
| "interleaved-thinking-2025-05-14", | ||
| "fine-grained-tool-streaming-2025-05-14", | ||
| // Note: fine-grained-tool-streaming removed for OAuth compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this beta header breaks the existing test in streaming-client.spec.ts at line 17, which expects fine-grained-tool-streaming-2025-05-14 to be present in defaultBetas. The test needs to be updated to remove this expectation.
Fix it with Roo Code or mention @roomote and request a fix.
| userAgent: `Roo-Code/${Package.version}`, | ||
| // User-Agent must match Claude Code's signature for OAuth tokens to be accepted | ||
| // Format matches opencode-anthropic-auth: "claude-cli/VERSION (external, cli)" | ||
| userAgent: `claude-cli/${Package.version} (external, cli)`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This userAgent format change breaks the test in streaming-client.spec.ts at line 21, which expects the pattern /^Roo-Code\/\d+\.\d+\.\d+$/. The test regex needs to be updated to match the new claude-cli/VERSION (external, cli) format.
Fix it with Roo Code or mention @roomote and request a fix.
The thinking_complete handler was re-emitting the full reasoning text after it had already been streamed via reasoning chunks. This caused the reasoning content to appear twice in the UI. Now the thinking_complete case only captures the signature for tool use continuations without re-emitting the text.
Summary
Fixes Claude Code OAuth token authentication issues by aligning the request shape with what Anthropic's API expects for OAuth tokens.
Changes
claude-cli/VERSION (external, cli)fine-grained-tool-streaming-2025-05-14(incompatible with OAuth)oc_prefix to tool names to bypass OAuth tool validationWhy tool name prefixing?
Anthropic's API validates tool names against a known list when using OAuth tokens. Third-party tools get rejected. By prefixing with
oc_we can use custom tool names while maintaining compatibility.What's preserved
prompt-caching-2024-07-31beta)interleaved-thinking-2025-05-14beta)Credits
This fix was inspired by research and implementation from:
Thanks to @anomalyco for the original research.
Test plan
Important
Fix OAuth compatibility by updating User-Agent, handling tool name validation with
oc_prefix, and removing incompatible beta headers.CLAUDE_CODE_API_CONFIGtoclaude-cli/VERSION (external, cli)for OAuth token acceptance.fine-grained-tool-streaming-2025-05-14from beta headers for OAuth compatibility.oc_prefix to tool names inprefixToolName()andprefixToolNames()for outgoing requests instreaming-client.ts.oc_prefix from tool names in responses usingstripToolNamePrefix().prefixToolNamesInMessages().terms.mdwith new terms of service effective January 9, 2026.This description was created by
for eb060a2. You can customize this summary. It will automatically update as commits are pushed.