fix(ai): route subscription auth through the configured proxy - #2184
Merged
Conversation
Subscription OAuth login, token refresh, and credential resolution now honor the global AI proxy (ai.proxy), including bare host:port URLs normalized to http://. Applies to Codex, Antigravity, and OpenCode subscription providers, and aligns TLS verification with the model configuration. Also reuse the credential committed by a concurrent refresh when the local conditional commit loses the race, instead of always failing on a revision conflict.
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
Subscription OAuth login, token refresh, and credential resolution now honor the global AI proxy (
ai.proxy). This applies to the Codex, Antigravity, and OpenCode subscription providers, whose token exchange, refresh, and account-discovery requests run outside the normal AI request client and previously ignored the proxy configuration.Bare
host:portproxy URLs (e.g.127.0.0.1:7897) are normalized tohttp://host:port; explicit schemes such assocks5://are preserved.TLS verification for subscription-auth requests now follows the model configuration (
skip_ssl_verify) and uses the same TLS backend as the main AI client.Changes
build_http_clientbuilds a proxy/TLS-aware client shared by all three subscription providers;build_proxynormalizes bare proxy URLs.SubscriptionHttpOptionscarries the transport policy (proxy +skip_ssl_verify) through login, refresh, and resolution.client_factoryresolves subscription credentials with the model's proxy and TLS settings.commandspasses the configured AI proxy into subscription login and account refresh.Also included
When a local token refresh loses its conditional-commit race to a concurrent refresh, the credential committed by the winner is reused if still valid, instead of always failing on a revision conflict.
Verification
cargo fmt(changed files viaformat-changed-rust)cargo checkforbitfun-ai-adapters(withsubscription-auth),bitfun-core,bitfun-desktopcargo testforbitfun-ai-adapters(full suite),bitfun-core,bitfun-desktopReview follow-up
apply_subscription_authcompatibility entry point.bitfun-ai-adapters, with a crate-specific dependency boundary contract and regression coverage.Additional verification
cargo test -p bitfun-ai-adapters --features subscription-auth(271 passed)cargo test -p bitfun-core --no-default-features --features ai-adapter-runtime --lib infrastructure::ai::client_factory::tests(6 passed)cargo check -p bitfun-desktopcargo test -p bitfun-desktop(283 passed, 2 ignored)pnpm run check:core-boundaries:test(68 passed)pnpm run check:core-boundariesgit diff --check