Add shared-home account session switching - #1
Open
patrickallensimpson wants to merge 1 commit into
Open
Conversation
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
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 responseTests
cargo fmt --all -- --checkcargo clippy --tests -p codex-app-server -p codex-backend-client -p codex-app-server-protocolcargo nextest run --no-fail-fast -p codex-app-server account_sessions_share_codex_home_and_isolate_credentialscargo nextest run --no-fail-fast -p codex-app-server-protocol -p codex-backend-clientThe end-to-end app-server test creates two accounts under one temporary home, switches between them, verifies credential isolation, and asserts that neither token appears in the shared metadata file.
Follow-up scope
This is the server-side lifecycle and storage layer. 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.