Account Pool: route Codex accounts through the hub over WebSocket - #3056
Open
SawyerHood wants to merge 2 commits into
Open
Account Pool: route Codex accounts through the hub over WebSocket#3056SawyerHood wants to merge 2 commits into
SawyerHood wants to merge 2 commits into
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.
Stack layer 3 (Codex pool track). Prerequisites: #3053 and #3054 below it. Single-plugin design: Codex joins the existing Account Pool plugin as a provider adapter.
Human comments
What was wrong
Account Pool was coupled to Claude credentials, request rewriting, quota headers, and refresh behavior, so it could not select or maintain Codex OAuth accounts. Codex also attempts the Responses WebSocket protocol before HTTP SSE, while the Codex bridge launched
codex app-serverwithout applying provider-contributed per-thread base URL and hub authentication values. Pointing Codex at the hub therefore required both a provider-neutral pool core inside the plugin and a session-aware app-server launch path.What changed
plugins/account-pooland preserved the existing Claude behavior behind its adapter.~/.codex/auth.json, serialized pre-expiry refresh with write-back, ChatGPT account identity storage, and provider-scoped account selection.x-codex-primary-*/x-codex-secondary-*rate-limit observations and quota rejections.POST /v1/responses,GET /v1/models, and WebSocket/v1/responsesroutes in the existing Account Pool/http/namespace.bb poolCLI and Account Pool settings section with Codex import, provider badges, shared machine tokens, Codex environment and health contributions, and provider-aware status.-c openai_base_url=...configuration, add an environment-backed hub header without putting the token in process arguments, and rebuild a session when pool routing or token identity changes.plugins/account-pool.There is no server/host-daemon wire contract change, so
HOST_DAEMON_PROTOCOL_VERSIONdoes not need a bump. There is no new public Plugin SDK surface in this layer.Not in this PR
model_provider="openai"while adding the machine-token header is not possible with Codex CLI 0.153.2: a live app-server launch rejectsmodel_providers.openaibecause built-in provider IDs are reserved and cannot be overridden. The bridge therefore retains the custombb-account-poolprovider ID. That changes the provider recorded in newly pooled rollouts and may affect Codex's provider-keyed session grouping, remote compaction, and remote-control behavior. Compatibility for existing sessions was verified live: a rollout created withmodel_provider: "openai"completed a direct turn, Account Pool was enabled, and the same rollout resumed and completed a pooled WebSocket turn.How you verified
The new focused regressions fail on the layer-A base because Codex is not an Account Pool provider there and the bridge ignores per-session pool configuration. They now cover import parsing, refresh persistence, HTTP credential/account-id rewrite, provider-scoped selection, Codex quota parsing and rotation, WebSocket authentication/prewarm/incremental/unknown-id/session streaming behavior, provider env/health, UI import and badges, and token-free app-server launch arguments.
pnpm exec turbo run typecheck test --filter=bb-plugin-account-pool --filter=bb-plugin-provider-codex --continue --force— 8/8 tasks passed; Account Pool 41/41 tests and Codex provider 261/261 tests passed; both typechecks passed. The added regression closes a downstream WebSocket during a non-terminating SSE response and proves the upstream abort signal fires, the account's in-flight count returns to zero, and no post-close frame is sent.pnpm exec turbo run test typecheck --filter=@bb/server --filter=@bb/app --filter=@bb/templates --filter=@bb/cli --continue— 15/15 tasks passed; server 2,209, app 3,872, templates 43, and CLI 530 tests passed; 4 app tests skipped; all selected typechecks passed.bb plugin build plugins/account-pool— production server and app bundles built successfully.node scripts/check-provider-literal-ratchet.mjs— passed with all core provider literals allowlisted.node .github/workflows/check-plugin-sdk-version.mjs— passed against the layer-A SDK surface/version state.git diff --check— passed.BB93_POOL_WS_OK, emitted the Account Pool WebSocket transport marker, and updated five-hour utilization to 0.4% without fallback/retry noise. The resolved-env card showed the Account Pool base URL and masked token. Afterbb pool bypass, a direct turn returnedBB93_DIRECT_OKwhile the pool observation timestamp stayed unchanged. Settings and timeline screenshots were inspected and attached to BB-93.openaiprovider override failed with the reserved-provider validation error. With Account Pool disabled, rollout01a06b6b-a3a4-7de2-9d07-d98af7bc5c90recordedmodel_provider: "openai"and returnedBB93_PREPOOL_OPENAI_OK; after enabling Account Pool, that same rollout returnedBB93_RESUMED_THROUGH_POOL_OKover the plugin WebSocket route and advanced pool utilization from 0.40% to 0.41% with no account error.Tracks BB-93 (layer B).