Skip to content

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.

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.

  1. Add each account. This runs codex login inside the new account’s folder. Finish the sign-in in the browser.

    Terminal window
    agent-switch add work --provider codex
    agent-switch add personal --provider codex
  2. Turn on the wrapper, if you have not yet, and open a new terminal.

    Terminal window
    agent-switch shellenv install
  3. Start Codex as usual.

    Terminal window
    codex

import turns your current ~/.codex login into an account without signing in again:

Terminal window
agent-switch import work --provider codex

The 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:

Terminal window
agent-switch login work --provider codex

login 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.

Terminal window
agent-switch status --provider codex

The background service refreshes Codex usage like Claude usage, and the desktop app shows the same meters.

Because Codex reports usage, everything that depends on it works:

  • Balanced starts. A codex start 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 codex
    agent-switch pool add work codex/work
  • Limit protection and suggestions. Protection warns at 98% by default, and autoswitch on --provider codex suggests another account near the limit.

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.

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:

Terminal window
agent-switch reset work --provider codex

reset 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.

Terminal window
agent-switch sessions --provider codex
agent-switch takeover <session-id> --to personal --provider codex
  • takeover moves a Codex session to another account and resumes it there with codex resume. It is move-only: --keep-source is not available.
  • sessions rm --provider codex uses Codex’s own codex archive, or codex delete with --purge.
  • handoff can carry the gist of a Claude session over to Codex, and back.

See Move a session for the details.

FeatureWhy
One account, one session (the guard)Codex writes no marker for a running session, so a busy account cannot be detected.
Live session markersSame 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 inClaude only. A Codex login renews when you use that account.
Session previewsNot available; the preview stays empty.
share, hooks, webClaude only.

On macOS, Agent Switch can open the Codex desktop app or VS Code with the Codex extension as a specific account:

Terminal window
agent-switch open codex-desktop work # the Codex app
agent-switch open codex-ide work # VS Code, for the Codex extension
agent-switch launcher add codex-desktop work

The 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.