Fix stale OAuth token causing silent failures in long-running proxy#2
Open
WilsonLiu95 wants to merge 1 commit into
Open
Fix stale OAuth token causing silent failures in long-running proxy#2WilsonLiu95 wants to merge 1 commit into
WilsonLiu95 wants to merge 1 commit into
Conversation
When the proxy is launched from Claude Desktop (or any process that sets CLAUDE_CODE_OAUTH_TOKEN), the env var is a point-in-time snapshot. The Claude CLI prioritizes this env var over the OS keychain, so subprocesses keep using the stale token even after Claude Desktop refreshes the keychain credential. Once the original token's usage window expires, all subprocess requests fail with "out of extra usage" (HTTP 400) while the keychain token remains perfectly valid. The proxy returns SSE error chunks that the OpenAI SDK silently drops, causing downstream consumers (e.g. OpenClaw gateway) to receive empty responses with no error indication. Fix: strip CLAUDE_CODE_OAUTH_TOKEN from the subprocess environment so the CLI falls back to reading fresh credentials from the OS keychain on every invocation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDE_CODE_OAUTH_TOKENfrom subprocess environment so the CLI reads fresh credentials from the OS keychain on every invocationnohup,launchd, orsystemd)Problem
When the proxy is launched from Claude Desktop (or any parent process that sets
CLAUDE_CODE_OAUTH_TOKEN), the env var is a point-in-time snapshot. The Claude CLI prioritizes this env var over the OS keychain, so subprocesses keep using the stale token even after Claude Desktop refreshes the keychain credential.Once the original token's usage window expires, all subprocess requests fail with
"You're out of extra usage"(HTTP 400), while the keychain token remains perfectly valid. The proxy returns SSE error chunks that the OpenAI SDK silently drops, causing downstream consumers to receive empty responses with no error indication.Root cause chain
Fix
Remove
CLAUDE_CODE_OAUTH_TOKENfrom the subprocess environment. This forces the Claude CLI to fall back to reading fresh credentials from the OS keychain (which Claude Desktop keeps up to date automatically).Test plan
🤖 Generated with Claude Code