Skip to content

feat: let clients request a replacement ChatGPT login - #729

Open
jsulopzs wants to merge 1 commit into
agentclientprotocol:mainfrom
jsulopzs:feat/replace-chatgpt-login
Open

jsulopzs wants to merge 1 commit into
agentclientprotocol:mainfrom
jsulopzs:feat/replace-chatgpt-login

Conversation

@jsulopzs

@jsulopzs jsulopzs commented Nov 2, 2026

Copy link
Copy Markdown

Problem

Since #247, authenticate with chat-gpt or chat-gpt-device-code succeeds at once when a working ChatGPT login exists. That is the right default, but it leaves a client no way to switch to another ChatGPT account: the only path is logout first, which leaves the user without any login if the new sign-in is cancelled or fails.

Fix

  • Both ChatGPT methods advertise _meta: { replaceLogin: true } in authMethods, on ACP v1 and v2.
  • When authenticate carries _meta: { replaceLogin: true }, the adapter skips the working-login check and starts the login (account/login/start) as usual: the browser flow for chat-gpt, the URL elicitation for chat-gpt-device-code.
  • Codex keeps the current account until the new login completes, and replaces it only then. A cancelled or failed login leaves the current account untouched.
  • Without _meta.replaceLogin, nothing changes.

Verification

  • Tests: the replacement browser login starts with a working login and keeps the current account until completion (success and failure); the device-code replacement starts and keeps the account when cancelled; v1 and v2 initialize advertise replaceLogin on both methods. The new tests fail without the change. Build, typecheck and the full suite pass.
  • Through a real client (CodeCompanion over ACP) with a working ChatGPT login: the replacement chat-gpt login opened the browser sign-in page; closing it without signing in left the same account in place and the session kept working.

This touches the same functions as #696 (login cancellation and isolation); whichever lands second needs a small rebase.

With a working ChatGPT login, authenticate with chat-gpt or chat-gpt-device-code returns at once (agentclientprotocol#247), so a client cannot switch to another ChatGPT account. A client may now send _meta.replaceLogin to start the login anyway; both methods advertise it. The current account stays in place until Codex completes the new login, and a cancelled or failed login leaves it untouched.
@jsulopzs
jsulopzs marked this pull request as ready for review November 2, 2026 23:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant