fix(proxy): port post-dispatch failover to OpenAI chat completions#773
Open
rohith500 wants to merge 5 commits into
Open
fix(proxy): port post-dispatch failover to OpenAI chat completions#773rohith500 wants to merge 5 commits into
rohith500 wants to merge 5 commits into
Conversation
Lock in ProxyOpenAIChatCompletion parity with Messages for OSS-outage baseline failover (happy path + negative cases) before the port. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
When a cost-routed OSS binding fails on the OpenAI wire, retry the caller-requested Anthropic model pre-commit — same eligibility and commit gates as ProxyMessages. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Cover live 429 and OAuth 401/403 arms on ProxyOpenAIChatCompletion before porting the Messages subscriptionRetryEligible path. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Retry Anthropic-routed OpenAI turns on the Weave/BYOK key after subscription 429 or OAuth 401/403, matching ProxyMessages. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Keep new comment blocks under the comment-length review threshold. 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. |
This was referenced Jul 17, 2026
Contributor
|
Thanks @rohith500 — conforms to the repo conventions, no rewrite needed. 👍 The baseline and subscription failover ports mirror the ProxyMessages predicates on |
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
ProxyOpenAIChatCompletionhad no post-dispatch failover: neither baselineretry (OSS outage → requested Anthropic model) nor subscription-credit
retry (OAuth 429/timeout or 401/403 → Weave/BYOK key). Both already work in
ProxyMessages. Live pre-fix: identical OSS-outage fixture returned raw503 with
anthropicCount=0on OpenAI while Messages recovered via Anthropic.Full root-cause and evidence: #771
Fix
Port both mechanisms into
ProxyOpenAIChatCompletion, same eligibility andpre-commit gates as Messages. Design choice: second full port (not a shared
helper) because emit/flush paths differ (OpenAI uses
PrepareAnthropic+SSE translator; Messages uses Anthropic-native SSE). Local
openaiAnthropicAttemptis reused by both retry sites on the OpenAI pathonly —
ProxyMessagesis untouched.model-not-found and the caller requested a known Anthropic catalog model.
with
IsRetryableoranthropicOAuthCredentialRejected(401/authentication_error, 403/permission_error).Out of scope (called out in #771)
only covers the reactive subscription-retry half of that composite case.
failover_used/fallback_attemptstelemetry accuracy when a cross-binding retry ran but the request still failed — same Messages semantics;
left alone to avoid OpenAI-only asymmetry.
Tests
TestProxyOpenAI_OSSOutageFailsOverToBaselineAnthropic(+ negatives:forced model, requested OSS, Anthropic excluded)
TestProxyOpenAI_SubscriptionRetry_Live429FailsOverToDeployKeyTestProxyOpenAI_SubscriptionRetry_OAuth401FailsOverToDeployKeyTestProxyOpenAI_SubscriptionRetry_OAuth403FailsOverToDeployKeyLive verification (committed tip)
claude-opus-4-8→ 200Test plan
make checkgreengo test ./internal/proxy/... -raceclean except knownTestFireTelemetryRecoversFromPanicflakeProxyMessagesregion unchanged (diff only inProxyOpenAIChatCompletion)Fixes #771
Made with Cursor