DEV Community

vild da
vild da

Posted on

Why Codex history disappears after switching providers (and how I fixed it)

I ran into an annoying Codex problem while switching between official OpenAI auth and relay/custom providers.

The sessions were not actually gone. What broke was session visibility.

In practice, the symptoms looked like this:

  • old sessions were visible under one provider, then disappeared after switching to another one
  • codex resume and Codex App did not always show the same history
  • changing only the rollout files was not enough

Why this happens

Codex stores provider-related session metadata in two places:

  • rollout files under ~/.codex/sessions and ~/.codex/archived_sessions
  • SQLite state in ~/.codex/state_5.sqlite

If only one layer is updated, the history may still look inconsistent. That is why a session can appear to be "missing" even though the actual data is still there.

What I built

I built codex-provider-sync to align both layers together.

It can:

  • inspect the current provider distribution
  • sync rollout metadata and SQLite state to a target provider
  • optionally update root model_provider in config.toml
  • create a backup before each run
  • restore from backup if needed
  • skip locked live rollout files and report them clearly

Windows GUI

I also added a Windows GUI so normal users do not need Node or npm anymore.

The GUI can:

  • scan the current .codex home
  • show provider distribution from rollout files and SQLite
  • let you pick a target provider and execute the sync
  • optionally update root model_provider
  • restore from backup
  • automatically keep the newest 5 managed backups by default, with configurable retention

Links

If you have hit the "my Codex history disappeared after switching providers" problem, this is exactly what the tool is meant to fix.

Top comments (0)