Skip to content

Keep the Codex state database on compute-local disk - #877

Merged
SaladDay merged 1 commit into
mainfrom
keep-codex-state-database-local
Oct 25, 2026
Merged

SaladDay merged 1 commit into
mainfrom
keep-codex-state-database-local

Conversation

@SaladDay

@SaladDay SaladDay commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Every Codex app-server start opens its SQLite databases (thread index, history projection, logs and others) from CODEX_SQLITE_HOME, which defaults to CODEX_HOME. On hosted placements CODEX_HOME sits in the state directory on NFS workspace storage, so a new Codex Session spent about 1.1 s just opening them.

The adapter now points CODEX_SQLITE_HOME at the Session's directory under the Runtime home on the compute's own disk. CODEX_HOME, with the rollouts, config and native history, stays in the state directory. The variable is added to the tool environment's skip list next to CODEX_HOME, and the Codex Runtime guide states the placement and its reason.

Measured on mx (microsandbox on NFS, MiniMax-M2.7, n=5 each), executor native_prepare for a new Codex Session:

min–max median
main (SQLite in CODEX_HOME on NFS) 1482–1744 ms 1501 ms
this branch 374–424 ms 387 ms

Why compute replacement loses nothing the Session needs:

  • Codex looks up a thread the index lacks by searching the rollouts, rebuilds the history projection from the rollout, and reads dynamic tools from the rollout's session metadata.
  • Goals keep their state only in SQLite. Disable Codex goals so no work outlives the Turn #876 disabled them.
  • Memories are off by default and keep only extraction bookkeeping in SQLite.
  • The queue is used only by the experimental thread/queue/* API, which the adapter does not call.

Live check on mx: a Codex Session remembered a code word. Then, inside its VM, its SQLite directory was emptied and the app-server killed. The next Turn started a new executor, which recreated the databases. It resumed the same rollout and answered with the code word. A plain suspend and resume keeps the VM's memory and disk, so it never reaches this path.

Verification on mx, from a checkout bundle of this tree: hosted acceptance 9/9 for Codex and 9/9 for Claude Code. Locally, go vet and go test pass for apps/daemon/internal/agent/codex and apps/daemon/internal/dispatch.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@SaladDay
SaladDay merged commit 2739783 into main Oct 25, 2026
21 checks passed
@SaladDay
SaladDay deleted the keep-codex-state-database-local branch October 25, 2026 10:10
Codex opens its SQLite databases on every app-server start. Under the hosted state directory, which lives on NFS workspace storage, a new Codex Session's native_prepare took 1.48-1.74 s on mx (n=5); with CODEX_SQLITE_HOME under the Runtime home on the VM's own disk it took 0.38-0.44 s (n=5). Nothing the Session needs is lost when the compute is replaced: Codex rebuilds the thread index and history views from the rollouts in CODEX_HOME and reads dynamic tools from the rollout, and goals, whose state lives only in SQLite, are disabled.
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