fix(ai): isolate and align subscription provider requests - #2882
Merged
bobleer merged 2 commits intoSep 8, 2026
Conversation
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 imports could retain stale authentication headers, use the wrong protocol for an account model, or omit request affinity on standalone calls. Resolve these rules from the signed-in provider and attach an explicit subscription identity to runtime clients. Ordinary API-key clients keep their existing routing, custom headers, request bodies, and editor controls, even when pointed at the same provider URLs.
x-opencode-sessionidentity once per logical call and retain it across retries.anthropic/*, with its current Chat Completions default; preserve the Nous refresh-header contract and existing credentials.Type and Areas
Type: bug fix
Areas: AI adapters, Rust client factory, desktop/Tauri, Web UI model settings, documentation.
Motivation / Impact
Users can import subscription models without manually choosing transport protocols or supplying account headers. Login, refresh, account switching, and logout update the runtime configuration without rewriting saved credentials or model IDs. API-key clients do not opt into subscription policy through URL matching.
Verification
Automated checks completed on macOS:
cargo test -p openbitfun-ai-adapters --features subscription-auth --lib— 362 passed.cargo test --locked -p openbitfun-ai-adapters --features subscription-auth --lib subscription_auth— 79 passed. The Hermes refresh request test also passes alone with--exact, using the production HTTP client constructor to initialize TLS independently of test order.cargo test -p openbitfun-ai-adapters --lib providers::— 60 passed, including ordinary API requests at subscription origins.cargo test -p openbitfun-core --no-default-features --features ai-adapter-runtime,subscription-auth --lib infrastructure::ai::client_factory::tests— 9 passed; rerun after updating the branch to upstreamc88b25fa5.cargo test -p openbitfun-core --no-default-features --features ai-adapter-runtime --lib infrastructure::ai::client_factory::tests— 8 passed.cargo check -p openbitfun-desktop— passed.cargo test -p openbitfun-desktop --lib— 430 passed, 7 ignored.pnpm --dir src/web-ui run test:run src/infrastructure/config/components/modelDiscoveryCoordinator.test.ts src/infrastructure/config/components/subscriptionLoginCoordinator.test.ts— 12 passed; rerun after updating the upstream base.pnpm run check:webandpnpm --dir src/web-ui run type-check— passed.pnpm run fmt:rs,git diff --check, andnode scripts/check-git-object-sizes.mjs --base upstream/main --head HEAD— passed.Other checks above were completed before incorporating the two non-overlapping upstream merges. Regression coverage includes legacy credential/config deserialization, credential round trips, stale account cache invalidation, per-request affinity, standalone retries, provider/origin isolation, and API-key custom-header/body preservation.
Reviewer Notes
AI-assisted contribution. Testing level: lightly tested end to end, with the automated coverage above. Real account login/refresh/inference and live remote workspace, remote control, Peer Device Mode, and Detached Dispatch scenarios were not exercised. Local fixtures do not establish remote behavior. Account-backed UI screenshots were not captured.
Protocol comparisons are documented in the adapter guide against OpenCode v1.18.29 and Hermes Agent. No persisted schema or remote wire contract is added. Unknown legacy OpenCode models retain their previous route; required subscription overrides remain runtime-only.
Checklist