Codex accounts
If you have more than one ChatGPT plan, Agent Switch keeps every Codex account
signed in next to the others and starts each codex session on the one with
the most left. Codex is on by default, next to Claude Code.
Most of Agent Switch works the same for both tools. This page covers what is specific to Codex, and what does not work for it yet.
How the accounts stay apart
Section titled “How the accounts stay apart”Codex reads its login and settings from the folder in CODEX_HOME. Each Codex
account gets its own folder, ~/.agent-switch/codex/<name>/config, and the
codex shell wrapper sets CODEX_HOME to the right one before it starts the
real codex. Your normal ~/.codex stays as it is.
Add your accounts
Section titled “Add your accounts”-
Add each account. This runs
codex logininside the new account’s folder. Finish the sign-in in the browser.Terminal window agent-switch add work --provider codexagent-switch add personal --provider codex -
Turn on the wrapper, if you have not yet, and open a new terminal.
Terminal window agent-switch shellenv install -
Start Codex as usual.
Terminal window codex
Keep the login you already have
Section titled “Keep the login you already have”import turns your current ~/.codex login into an account without signing
in again:
agent-switch import work --provider codexThe imported account still shares its login with your normal Codex install, so Agent Switch never balances onto it. Give it a login of its own when you are ready:
agent-switch login work --provider codexlogin is also how you sign an account in again after its login expired.
For each Codex account, Agent Switch reads the live limits from ChatGPT’s own
usage endpoint (chatgpt.com/backend-api/wham/usage), using that account’s own
token. It shows the windows your plan reports, typically the 5-hour and the
weekly limit, plus the number of banked resets.
agent-switch status --provider codexThe background service refreshes Codex usage like Claude usage, and the desktop app shows the same meters.
Balanced starts, pins and pools
Section titled “Balanced starts, pins and pools”Because Codex reports usage, everything that depends on it works:
-
Balanced starts. A
codexstart without a folder pin goes to the account that would lose the most of its remaining quota at its next reset. -
Folder pins and pools. Pin a folder for Codex with
--provider codex. Pins are per tool, so one folder can use one Claude account and another Codex account.Terminal window agent-switch map work --provider codexagent-switch pool add work codex/work -
Limit protection and suggestions. Protection warns at 98% by default, and
autoswitch on --provider codexsuggests another account near the limit.
Fresh limits
Section titled “Fresh limits”The background service reads a Codex account’s limits every minute while
codex runs on it, and every 5 minutes otherwise. Codex also writes its limits
into its own session file after every turn; the service takes those numbers as
soon as they are newer, without a network call. When an account that sat at its
limit passes its reset time, it is read again right away and you get one “free
again” notice.
Banked resets
Section titled “Banked resets”A ChatGPT plan can hold banked rate-limit resets. The desktop app shows how
many each account has. With limit suggestions on for Codex
(agent-switch autoswitch on --provider codex), the notice for a preferred
account over the threshold also says when a reset is available.
To redeem one yourself:
agent-switch reset work --provider codexreset waits until the usage readout shows the cleared limit, so the app and
the next start see the new numbers right away.
Agent Switch redeems one for you only if you turn it on
(agent-switch auto-reset on, or Settings › Protection › Redeem Codex resets
automatically). It is off by default. When it is on, an account that reaches
100 % gets one of its own banked resets, at most once per reset cycle.
Sessions
Section titled “Sessions”agent-switch sessions --provider codexagent-switch takeover <session-id> --to personal --provider codextakeovermoves a Codex session to another account and resumes it there withcodex resume. It is move-only:--keep-sourceis not available.sessions rm --provider codexuses Codex’s owncodex archive, orcodex deletewith--purge.handoffcan carry the gist of a Claude session over to Codex, and back.
See Move a session for the details.
What does not work for Codex
Section titled “What does not work for Codex”| Feature | Why |
|---|---|
| One account, one session (the guard) | Codex writes no marker for a running session, so a busy account cannot be detected. |
| Live session markers | Same reason: Codex sessions are listed as recent, never as live. Make sure none is running before you move one. |
rebind (switch a running session) | Claude only. |
| Keep accounts signed in | Claude only. A Codex login renews when you use that account. |
| Session previews | Not available; the preview stays empty. |
share, hooks, web | Claude only. |
Codex desktop and VS Code macOS
Section titled “Codex desktop and VS Code ”On macOS, Agent Switch can open the Codex desktop app or VS Code with the Codex extension as a specific account:
agent-switch open codex-desktop work # the Codex appagent-switch open codex-ide work # VS Code, for the Codex extensionagent-switch launcher add codex-desktop workThe Codex app gets the account’s CODEX_HOME and its own browser data folder,
so two accounts can run side by side. VS Code gets the account’s
CODEX_HOME. See
Desktop apps and launchers.