[codex] rework upstream strategy and codex fallback#176
Merged
Conversation
…ream-strategy-redesign-merge # Conflicts: # crates/token_proxy_core/src/proxy/config/io.rs # crates/token_proxy_core/src/proxy/config/migrate.rs # crates/token_proxy_core/src/proxy/config/migrate.test.rs # crates/token_proxy_core/src/proxy/config/mod.rs # crates/token_proxy_core/src/proxy/config/mod.test.rs # crates/token_proxy_core/src/proxy/config/types.rs # crates/token_proxy_core/src/proxy/http.test.rs # crates/token_proxy_core/src/proxy/server.test.rs # crates/token_proxy_core/src/proxy/service.test.rs # crates/token_proxy_core/src/proxy/upstream.rs # crates/token_proxy_core/src/proxy/upstream_selector.test.rs # messages/en.json # messages/zh.json # src/features/config/form.test.ts # src/features/config/form.ts
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
This PR closes the remaining high-confidence gaps from issues #174 and #175 without carrying forward the old upstream strategy format.
For issue #175, Claude
/v1/messagesrequests could not reach Codex even when the upstream explicitly allowedanthropic_messagesconversion. The provider selection and retry fallback pairing both skipped the Codex path, so users ended up withNo available upstream configuredor a dead-end fallback chain.For issue #174, the original implementation only supported serial retries plus a separate hedge delay experiment. That left the runtime model, config schema, UI, and docs describing different concepts. Users could not cleanly express “how to order candidates” separately from “how to dispatch requests”, and the old config shape could not scale to both hedged and race execution.
This change replaces the old string-based
upstream_strategywith a structured strategy object that splitsorderfromdispatch. The runtime now plans serial, hedged, and race execution from the same model. The config UI exposes the same structure directly, and the docs were rewritten to describe only the new format. To avoid leaving existing users broken after the schema change, config loading now performs a load-time migration from legacypriority_fill_first/priority_round_robinstrings to the new structured object and immediately writes the migrated config back to disk.The PR also keeps the Codex fallback fix for
/v1/messages, including request/response conversion and retry fallback pairing between Responses-family providers and Codex. The unrelated working tree change incrates/token_proxy_core/src/antigravity/oauth.rswas intentionally left out of this PR.Validation
pnpm run i18n:compilepnpm exec tsc --noEmitpnpm vitest runcargo fmtcargo test -p token_proxy_corecargo test -p token_proxy