Deemwar Monads & Abstractions

The Codex daemon

Source: CLI: make daemon_auto_start opt-in — a persistent, self-updating background daemon shouldn't be the default, by Yihua-Liu-1997

Since Codex CLI 0.157.0, opening an interactive session starts a background server that keeps running after you close every window. It runs from its own copy of the package and updates itself. Here is what it does and how to turn it off.

0.157.0 first CLI version
~374 MB package copy
5 min then hourly update check
70 s updater alive after stop

What one session starts

The issue report walks through four things that happen when you type codex, in this order.

  1. 1

    A daemon starts

    codex app-server --managed-daemon

    It runs in its own session with no TTY. When the last window closes, it is reparented to PID 1 and keeps running until codex app-server daemon stop or a reboot.

  2. 2

    The package is copied

    ~/.codex/packages/app-server-daemon/releases/<version>/

    About 374 MB, byte-identical to what npm just installed. The daemon runs from this copy, so its version no longer follows the CLI you installed.

  3. 3

    An updater detaches

    codex app-server daemon pid-update-loop

    It checks for updates 5 minutes after start, then hourly. It downloads new releases and restarts the backend, which can kill active turns.

  4. 4

    The first environment sticks

    e.g. HTTPS_PROXY

    The daemon keeps the environment of whichever session started it. Later sessions with a different proxy still go out through the first one.

Close the window: the daemon and its updater stay.

Turn it off

codex app-server daemon stop alone is not enough: it stops the server but leaves the updater running, still alive 70 seconds later in the report. The reporter's full workaround:

StepCommand
Stop auto-startcodex features disable daemon_auto_start
Stop the servercodex app-server daemon stop
Kill the updaterpkill -f 'app-server daemon pid-update-loop'
Delete the copyrm -rf ~/.codex/packages/app-server-daemon

With the flag off, a new session no longer spawns a daemon. A commenter on Windows 10 confirms the same fix through daemon_auto_start = false in config.toml.

Read it fairly

Read more

The report: issue #48195 in the openai/codex repository, “make daemon_auto_start opt-in”.

Hacker News discussion.

The Short on this topic walks through the same four steps.

Sources: every number comes from the issue body (CLI 0.157.0 via npm, ~374 MB copy, 5 min then hourly checks, updater alive 70 s after stop); the config.toml line from a commenter on the same issue.