fix(proxy): suppress exhausted Claude subscription on OpenAI path#762
Open
rohith500 wants to merge 2 commits into
Open
fix(proxy): suppress exhausted Claude subscription on OpenAI path#762rohith500 wants to merge 2 commits into
rohith500 wants to merge 2 commits into
Conversation
…ption ProxyOpenAIChatCompletion must drop a spent Claude OAuth token when a deployment key exists, and refuse subscription-only turns when the observer reports exhaustion — locking both guards before the fix. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Mirror ProxyMessages so ProxyOpenAIChatCompletion drops a spent Claude OAuth token before credential resolution and refuses subscription-only turns when the observer reports exhaustion. Fixes workweave#761 Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
PR author is not in the allowed authors list. |
Contributor
|
Thanks for this, @rohith500 — really nice catch. 🙏 The OpenAI path was silently missing the exhausted-Claude-subscription handling that
Approving from a conventions standpoint — great contribution. |
This was referenced Jul 17, 2026
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
ProxyOpenAIChatCompletion never checked whether the caller's Claude
subscription was exhausted before injecting credentials, unlike
ProxyMessages (#519). On an OpenAI-wire turn routed to Anthropic, this meant
a spent OAuth token was dispatched instead of falling through to the
deployment/BYOK key. The subscription-only 402 guard had the same gap.
Full root-cause analysis and original live evidence: #761
Fix
Two changes in ProxyOpenAIChatCompletion, both mirroring ProxyMessages
exactly:
exhaustion, matching service.go:2373's exact composition:
Known composition gap (documented, not fixed here)
Messages' subscription-only guard is additionally gated by
&& !routeRes.UsageBypass; this PR doesn't add that exclusion on theOpenAI side. Verified this is inert today: usageBypassEngaged and
anthropicSubscriptionObservedExhausted read the identical usage-observer
snapshot (usage_bypass.go:93 and :136), so UsageBypass=true and
observed-exhausted=true cannot coexist — structurally, not just
empirically. Revisit when bypassToAnthropic/UsageBypass consumption is
wired on this surface (separate, not-yet-filed issue).
Tests
TestOpenAI_SubscriptionExhausted_ServesOnDeploymentKeyTestSubscriptionOnly_OpenAI_ExhaustedSubscription_Refuses402Both fail on main, pass on this branch. Landed in
usage_bypass_test.go,reusing existing fixtures (
bypassScorerPickMdl,bypassSubToken,fakeRouter,fakeProvider) rather than new mocks.Live verification (re-run against the actual committed diff, not a
local patch — git diff HEAD was empty throughout)
Test plan
make checkgreengo test ./internal/proxy/... -raceclean except pre-existingTestFireTelemetryRecoversFromPanicflakesubscription_only_openai_test.go) unaffected59966ccFixes #761
Made with Cursor