Skip to content

[codex] rework upstream strategy and codex fallback#176

Merged
mxyhi merged 4 commits intomainfrom
codex/structured-upstream-strategy-redesign
Mar 18, 2026
Merged

[codex] rework upstream strategy and codex fallback#176
mxyhi merged 4 commits intomainfrom
codex/structured-upstream-strategy-redesign

Conversation

@mxyhi
Copy link
Owner

@mxyhi mxyhi commented Mar 18, 2026

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/messages requests could not reach Codex even when the upstream explicitly allowed anthropic_messages conversion. The provider selection and retry fallback pairing both skipped the Codex path, so users ended up with No available upstream configured or 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_strategy with a structured strategy object that splits order from dispatch. 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 legacy priority_fill_first / priority_round_robin strings 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 in crates/token_proxy_core/src/antigravity/oauth.rs was intentionally left out of this PR.

Validation

  • pnpm run i18n:compile
  • pnpm exec tsc --noEmit
  • pnpm vitest run
  • cargo fmt
  • cargo test -p token_proxy_core
  • cargo test -p token_proxy

@mxyhi mxyhi marked this pull request as ready for review March 18, 2026 03:30
…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
@mxyhi mxyhi merged commit e3b5ea2 into main Mar 18, 2026
1 check passed
@mxyhi mxyhi deleted the codex/structured-upstream-strategy-redesign branch March 18, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant