Repository navigation
Add shared-home account session switching - #1
Open
patrickallensimpson wants to merge 2 commits into
Open
patrickallensimpson wants to merge 2 commits into
patrickallensimpson wants to merge 2 commits into
Conversation
patrickallensimpson
force-pushed
the
feature/shared-home-account-sessions
branch
from
September 12, 2026 07:12
8d38f63 to
81818e3
Compare
added 2 commits
September 14, 2026 13:53
What: - implement accountSession add, list, switch, and logout routes in app-server - isolate each saved login through the configured auth backend while keeping one shared CODEX_HOME for threads, rollouts, skills, and memories - exchange workspace-scoped tokens, reload active auth, and block account mutations during active turns - add generated protocol fixtures, app-server documentation, and an end-to-end two-account test Why: - users with multiple ChatGPT accounts currently need separate Codex homes, which fragments local sessions and memory and can break thread forking when rollout paths cross homes - the protocol types already existed, but the server lifecycle and secure credential persistence were missing Risks/Notes: - workspace metadata refresh is best effort; callers should refresh before selecting a non-current workspace - clients bootstrap the current login with accountSession/list, complete the existing login flow for another identity, then call accountSession/add - this does not add UI account switching Tests: - cargo fmt --all -- --check - cargo clippy --tests -p codex-app-server -p codex-backend-client -p codex-app-server-protocol - cargo nextest run --no-fail-fast -p codex-app-server account_sessions_share_codex_home_and_isolate_credentials - cargo nextest run --no-fail-fast -p codex-app-server-protocol -p codex-backend-client - stable and experimental app-server schema generation
What: - Use a shared read lock for independent turn admissions and an exclusive write lock for account mutations, retaining the active-turn rejection. - Reload saved OAuth credentials after auth refresh before applying a workspace-token response, preserving rotated refresh tokens when omitted. - Add public JSON-RPC regressions for eight overlapping thread turns, workspace refresh-token preservation and replacement, active-turn mutation guards, and switching model-request credentials within one conversation. Why: - Exclusive admission incorrectly treated another thread's turn start as an account change. A pre-refresh auth snapshot could overwrite rotated tokens. - Validate the shared-home feature against upstream b9bfc0a before publishing the rebased branch, rather than relying on a clean source merge. Risks/Notes: - This remains one active account per app-server; per-thread account routing and Desktop integration are separate work. - HTTP/OAuth integration uses synthetic credentials and local mock servers, not live account switching. - The broad suite is not fully green: nine code-mode tests lack the Windows codex-code-mode-host binary. Its required rusty_v8 150.4.0 Windows sandbox archive returns HTTP 404, preventing the helper build. Tests: - Six account-session cases passed; restoring exclusive admission and stale auth behavior made the two targeted regressions fail on both attempts. - just test -p codex-app-server -p codex-app-server-protocol -p codex-backend-client: 1890 passed, 9 failed, 12 skipped. All failures report the missing code-mode helper; one login test passed on retry. - Stable and experimental app-server schemas regenerated successfully. - just fix -p codex-app-server -p codex-app-server-protocol -p codex-backend-client completed; deliberate async admission guards have narrowly scoped lint expectations consistent with existing server code. - just clippy -p codex-app-server -p codex-app-server-protocol -p codex-backend-client -- -D warnings passed. - just fmt completed; unrelated Bazel formatter churn was excluded.
patrickallensimpson
force-pushed
the
feature/shared-home-account-sessions
branch
from
September 14, 2026 20:17
81818e3 to
4876ea4
Compare
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
accountSession/add,accountSession/list,accountSession/switch, andaccountSession/logoutprotocolCODEX_HOMEfor threads, rollouts, config, skills, and memories while isolating each account's credentialsaccount-sessions.json; tokens remain in the configured file, keyring, or secrets backend under a per-session namespaceMotivation
Using separate Codex homes isolates credentials, but it also fragments local threads and memories. It can additionally make a shared rollout unusable when a forked conversation is validated against a different home. This proposal makes account identity switchable independently of the local session store: one shared home owns the local working context, while each saved account session owns only its credentials and selected workspace.
Relationship to existing work
This builds on the account-session protocol types merged upstream in openai#25469 and provides a current-
mainimplementation of the lifecycle discussed in openai#25383. It also addresses the shared-session use case behind openai#4432 without requiring oneCODEX_HOMEper auth profile.The main storage distinction from openai#25383 is that bearer and refresh tokens are never serialized into
account-sessions.json. Existing auth backends remain the credential authority, namespaced by an opaque account-session ID.Safety properties
Debugimplementation on the backend token responseValidation on 2026-09-14
Rebased onto upstream
b9bfc0aff84de6af4c549f1ae544de569474f5f4(59 commits beyond the previous base). Source changes merged cleanly; stable and experimental binary schema bundles were regenerated using the current generators. Git range-diff reports the original feature patch unchanged by the rebase.The follow-up fix replaces exclusive turn admission with a reader/writer barrier and reloads persisted OAuth credentials after refresh before applying workspace-token replacements.
just test -p codex-app-server account_sessions: all six cases passed.just test -p codex-app-server -p codex-app-server-protocol -p codex-backend-client --failure-output final --status-level fail: 1,890 passed, 9 failed, 12 skipped. Protocol: 304/304 passed; backend client: 32/32 passed. One existing login redirect test passed on retry.codex-code-mode-hostexecutable. Building it was attempted, but the required rusty_v8 150.4.0 Windows sandbox archive returned HTTP 404. The separatetest_stdio_serverhelper was built successfully. This is not a fully green broad-suite result.just fmtcompleted; unrelated Bazel formatting churn was excluded.just fixcompleted, andjust clippy -p codex-app-server -p codex-app-server-protocol -p codex-backend-client -- -D warningspassed. Intentional async admission guards have narrowly scoped lint expectations following existing server conventions.The public JSON-RPC tests cover credential isolation and token-free metadata, eight overlapping turns on independent threads, refresh-token preservation when omitted and replacement when supplied, rejecting add/switch/logout while a model response is gated, and allowing switching after completion. Another test keeps one conversation across two turns and verifies the second model request has the new bearer/account headers while retaining the earlier conversation input. HTTP/OAuth tests use synthetic credentials and local mock servers, not real accounts.
Follow-up scope
GitHub CI limitations observed after publication
The PR is mergeable, but CI is not green. Several SDK/Windows jobs fail before execution because the private fork does not have the required
codex-runnersrunner group. Therepo-checksjob also reports a stalecode-modeentry inMANIFEST_FEATURE_EXCEPTIONS; both that checker andcodex-rs/code-mode/Cargo.tomlare unchanged from upstreamb9bfc0aff84d. These failures are recorded separately from the validated account-session changes; runner provisioning and upstream manifest-policy cleanup were not changed in this PR.This is the server-side lifecycle and storage layer with one active account per app-server. Per-thread account routing and Desktop integration are separate follow-ups. A UI account picker and a dedicated
accountSession/login/startUX can be layered on separately; clients can currently bootstrap the store withlist, use the existing login flow, and then calladd.Upstream PR creation was attempted directly but the account was denied the
CreatePullRequestpermission. This fork PR is the reviewable proposal and branch of record.