codex-hotswap automatically switches Codex to another logged-in account when the current one hits usage limits, while keeping normal repo history and /resume, even across multiple wrapped Codex sessions.
If you use Codex heavily in the terminal, you eventually hit this:
- you are working in a repo
- your current Codex account runs out of usage
- your work stops
- you manually switch accounts and try to recover the session
codex-hotswap removes that manual account juggling.
You log into multiple Codex accounts once, then keep using normal codex.
When one account hits limits, codex-hotswap switches to the next one and resumes the session.
- Linux: supported
- macOS: expected to work, but less field-tested
- Windows native: not supported yet
- Windows users should use WSL for now
If you just want the shortest setup path, do this.
On Ubuntu or Debian:
sudo apt update
sudo apt install -y pipx
pipx ensurepathRestart your shell after pipx ensurepath.
pipx install git+https://github.com/tanayyo1/codex-hotswap.gitcodex-hotswap setup --force --count 4 --prefix acc --login --install-shimWhat this does:
- creates
acc1,acc2,acc3,acc4 - asks you to log in to each account
- installs a small shim so normal
codexruns throughcodex-hotswap
Each account login is still interactive. The command walks you through them one by one.
codex-hotswap use acc1cd ~/your-repo
codexThat is the normal daily workflow after setup.
You can open multiple wrapped codex sessions in different repos or tabs. Each wrapped launch now gets its own private runtime overlay while still sharing the normal Codex session store.
Turn hotswap off:
codex-hotswap disable
hash -rdisable also primes your shared ~/.codex auth from the current target so plain codex works right away.
Turn hotswap back on:
codex-hotswap enable
hash -rUse this if you want to work in many plain Codex tabs for a while and do not need automatic account failover in those sessions.
Most users only need:
cd ~/your-repo
codexIf the current account hits limits, codex-hotswap should rotate to the next account automatically.
codex-hotswap uses three layers of storage:
- shared Codex store:
~/.codex - per-account auth vaults:
~/.codex-acc1,~/.codex-acc2, and so on - per-session runtime overlays: created automatically under
~/.local/state/codex-hotswap/runtime
What stays shared:
- repo history
- normal
/resume - the Codex session store
What stays separate:
- each account login
- each live wrapped session's
auth.json
When you launch wrapped codex:
codex-hotswapcreates a temporary runtimeCODEX_HOME- it links that runtime home back to the shared Codex store
- it copies the selected account auth into that runtime home
When a limit is hit:
- the current account is marked exhausted
- the next account auth replaces only the runtime overlay's private
auth.json codex resume --lastis attempted
What should stay the same:
- repo directory
- normal
/resumebehavior - overall session flow
What should change:
- the logged-in account
Why this matters:
- wrapped sessions can run in parallel now
- one wrapped session changing accounts no longer changes the auth underneath another wrapped session
Example real use:
- you are in
~/tonr - you run
codex - Codex is using
acc1 acc1hits a usage limitcodex-hotswapswitches toacc2- Codex continues in the same repo
The important signal is:
- same repo
- same general session/thread flow
- different
Account:line
codex-hotswap doctor
codex-hotswap status
codex-hotswap current
codex-hotswap use <target>
codex-hotswap next
codex-hotswap login <target>
codex-hotswap enable
codex-hotswap disable
codex-hotswap reset
codex-hotswap reset <target>
codex-hotswap install-shim
codex-hotswap uninstall-shimWhat they mean:
codex-hotswap doctor= check if setup is healthycodex-hotswap status= show targets and exhaustion statecodex-hotswap use acc1= choose starting accountcodex-hotswap login acc1= log in one accountcodex-hotswap enable= turn hotswap on for normalcodexcodex-hotswap disable= turn hotswap off, prime shared auth, and use normalcodexcodex-hotswap reset= clear exhausted markers
Instead of acc1, acc2, acc3, acc4, you can use names:
codex-hotswap setup --force --accounts main,work,backup,extra --login --install-shimFor headless or remote login:
codex-hotswap setup --force --count 4 --prefix acc --login --device-auth --install-shimcodex-hotswap doctorIf you see:
doctor status: okyour setup is healthy.
On Ubuntu or Debian:
sudo apt update
sudo apt install -y pipx
pipx ensurepathRestart your shell, then install again.
Create setup first:
codex-hotswap setup --force --count 4 --prefix accCheck:
- you are using
codexthrough the shim orcodex-hot - each account logged in successfully
- the target order in
codex-hotswap status - not all accounts are already exhausted
This means every configured target is currently marked exhausted.
Check:
codex-hotswap statusClear all exhaustion markers:
codex-hotswap resetOr start from a specific account:
codex-hotswap use acc3
codexTurn hotswap off:
codex-hotswap disable
hash -rTurn it back on later:
codex-hotswap enable
hash -rYou only need this if you want raw Codex with no automatic failover. Wrapped multi-session use is supported now.
Make sure you are starting through codex-hotswap, not through a separate unmanaged Codex setup with another CODEX_HOME.
Use:
cd ~/your-repo
codexWhat it does well:
- keeps normal repo/session history in a shared Codex store
- preserves
/resumebehavior by repo - isolates multiple account logins
- swaps account auth without changing your workspace
- supports multiple wrapped sessions by giving each one a private runtime overlay
What it does not guarantee:
- perfect detection of every future Codex failure banner
- a real upstream usage meter from Codex
- perfect resume behavior if Codex changes its internals
- perfect compatibility if Codex changes its storage layout significantly
No. If you install the shim, you can just use normal codex.
Yes. The shared Codex store keeps normal Codex history, so /resume should still stay organized by repo.
No. You still log into each account once. After that, switching is automatic.
No. Use WSL for now.
You can keep hotswap on now. Wrapped codex sessions use private runtime overlays, so multiple wrapped tabs are supported.
If you want raw Codex with no wrapper, turn hotswap off first:
codex-hotswap disable
hash -rThen open as many normal codex sessions as you want.
Turn hotswap back on later:
codex-hotswap enable
hash -rpython3 -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e '.[dev]'
python -m pytest
python -m build