Skip to content

OpenAI

Codex CLI 0.157.0 leaves a daemon running after you quit

3 min read

Written by an AI model from the linked sources and checked against them by a second model. How we work

All about: OpenAI models and products →
Image: github.com

Starting with Codex CLI 0.157.0, opening a single interactive session launches a background daemon that keeps running after every Codex window closes, a user reported in an issue on the openai/codex GitHub repo on October 12. The author asks OpenAI to make the daemon_auto_start flag opt-in. While that flag stays at its default, the daemon runs from its own copy of the binaries, updates itself every hour and can restart while a turn is still running. codex features disable daemon_auto_start stops new sessions from starting it, but codex app-server daemon stop leaves the updater running.

The author tested this on Linux under WSL2 with the npm install. The full cleanup took four steps, one of them a pkill, because the updater was still alive 70 seconds after daemon stop:

  • codex features disable daemon_auto_start
  • codex app-server daemon stop
  • pkill -f 'app-server daemon pid-update-loop'
  • rm -rf ~/.codex/packages/app-server-daemon

With the flag off, a new TUI session no longer started a daemon.

The process itself is codex app-server --managed-daemon. It runs in its own session with no terminal attached. Once the last window closes, it gets reparented to PID 1 and stays up until you stop it or reboot. It also doesn’t run the binary npm just installed. It runs from a copy of the whole platform package, about 374 MB including codex, codex-code-mode-host and bundled bwrap, zsh and rg, stored under ~/.codex/packages/app-server-daemon/releases/<version>/. That copy is byte-identical to npm’s on day one. From then on, though, the backend’s version is separate from the version your package manager thinks it installed.

That separation comes from the updater, codex app-server daemon pid-update-loop, which runs detached. It checks for a release 5 minutes after it starts and then every hour, downloads any new version and restarts the backend. An earlier issue that the author links reports that this auto-update force-kills active turns after a 60-second drain window and can’t be switched off. So a long build or test run started from Codex can be cut off by an update you never asked for.

The daemon also keeps the environment of whichever session happened to start it. The author launches Codex through a wrapper that sets HTTPS_PROXY for each run. The daemon kept the first session’s proxy variables and sent all its outbound traffic through that proxy, whatever the later sessions were started with. The author thinks the same cause is behind two other open reports. In one, hooks in --remote mode get the daemon’s working directory instead of the session’s. In the other, hooks can’t tell which terminal the client is in.

Package managers make it worse. Other issues linked from the report say npm update leaves the app-server on the old version and that the daemon’s own update and restart commands refuse to recover from that. They also say 0.157.0 won’t start from the Arch Linux package unless you pass --no-daemon. If the default stays, the author asks for two things: an auto-started daemon should exit when its last client disconnects, and Codex shouldn’t copy or self-update itself when npm, brew or pacman installed it. The author thinks a shared, self-updating daemon makes sense for Remote Control and the desktop app, or when a user runs codex app-server daemon start on purpose.

For the CLI, the author wrote, “the least surprising default is that the backend lives and dies with the window, runs the binary I installed, and doesn’t update itself in the background.”

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.