用户报告 Codex CLI 0.157.0 默认启动持久化自更新后台守护进程

来源:Codex:GitHub Releases(RSS) 2026年10月12日 03:25 AIHOT 评分:66 精选
摘要:一位 Linux (WSL2) 用户报告,Codex CLI 0.157.0 起打开交互式会话即默认启动持久后台守护进程 codex app-server --managed-daemon,窗口关闭后仍驻留。
推荐理由:作者实测 Codex CLI 0.157.0 的守护进程默认行为,给出复制目录、自更新、代理污染等细节和完整关闭步骤。
# 用户报告 Codex CLI 0.157.0 默认启动持久化自更新后台守护进程 > 原标题:Codex CLI 默认会安装一个持久化且能自动更新的后台守护进程 - 来源:Codex:GitHub Releases - 发布时间:2026-10-12T19:25:54.721Z - AIHOT:https://aihot.news/items/amjmxvrvj57q7752kgihp9p9q - 原文:https://github.com/openai/codex/issues/48195 ## 摘要 一位 Linux (WSL2) 用户报告,Codex CLI 0.157.0 起打开交互式会话即默认启动持久后台守护进程 codex app-server --managed-daemon,窗口关闭后仍驻留。 ## 推荐理由 作者实测 Codex CLI 0.157.0 的守护进程默认行为,给出复制目录、自更新、代理污染等细节和完整关闭步骤。 ## 正文 · 中文译文 ### 你使用的是哪个版本的 Codex? CLI — 0.157.0,通过 `npm install -g @openai/codex` 安装,Linux(WSL2) ### 你希望看到什么功能? 请让 `daemon_auto_start` **在 CLI 中选择启用(默认 `false`)**,或者至少在开启前询问一次。 自 0.157.0 起,只要打开一个交互式 `codex` 会话: 1. **会启动一个持久后台守护进程**(`codex app-server --managed-daemon`)。它在自己的会话中运行,没有 TTY,并且在每个 Codex 窗口关闭后仍会继续运行(被重新挂到 PID 1 下),直到 `codex app-server daemon stop` 或重启。 2. **会复制整个平台包**(约 374 MB:`codex`、`codex-code-mode-host`,以及捆绑的 `bwrap`/`zsh`/`rg`)到 `~/.codex/packages/app-server-daemon/releases//` —— 与 npm 刚刚安装的内容逐字节相同 —— 并从该副本运行守护进程。从那时起,后端的版本就与我用包管理器安装的 CLI 版本解耦了。 3. **会启动一个分离的更新器**(`codex app-server daemon pid-update-loop`),它在启动 5 分钟后检查更新,之后每小时检查一次,下载新版本并重启后端(这可能会终止正在进行的回合,见 [app-server daemon: auto-update force-kills active turns after a 60s drain budget, and cannot be disabled #40969](https://github.com/openai/codex/issues/40969))。 4. **会固定住恰好启动它的那个会话的环境。**我通过一个包装器启动 Codex,每次调用都会设置 `HTTPS_PROXY`;守护进程会保留第一个会话的代理变量,其出站连接都会经过那个代理,无论后续会话是用什么启动的。[Hooks in --remote mode receive the daemon's cwd, not the session's #42457](https://github.com/openai/codex/issues/42457) 和 [Hooks spawned by the app-server daemon cannot identify the client terminal, breaking terminal-targeting hooks #37537](https://github.com/openai/codex/issues/37537)(守护进程的 cwd / 终端而不是会话的)看起来是同一个根本原因。 对于 CLI 来说,最不令人意外的默认行为是:后端随窗口一起生灭,运行我安装的二进制文件,并且不会在后台自我更新。共享的、可自我更新的守护进程对 Remote Control / 桌面应用来说是有意义的,所以在那里启用它没问题,或者在用户显式运行 `codex app-server daemon start` / `bootstrap` 时启用也可以。 如果它仍默认开启,请至少: - 在最后一个客户端断开连接时退出自动启动的守护进程; - 当 CLI 是由包管理器(npm/brew/pacman)安装时,不要复制/自我更新 —— 而是运行已安装的二进制文件([Support externally managed app-server daemon executables #41188](https://github.com/openai/codex/issues/41188)、[npm update leaves app-server on old version, but daemon update/restart refuse recovery #46468](https://github.com/openai/codex/issues/46468)、[Codex 0.157.0 no longer starts with the Arch Linux package unless --no-daemon is used #48050](https://github.com/openai/codex/issues/48050))。 ### 附加信息 **在关闭它时发现的 bug:**`codex app-server daemon stop` 会停止 app-server,但会让 `pid-update-loop` 更新器继续运行(70 秒后仍然存活,不得不手动杀掉它)。 我正在使用的变通方法: codex features disable daemon\_auto\_start codex app-server daemon stop pkill -f 'app-server daemon pid-update-loop' # not stopped by \`daemon stop\` rm -rf ~/.codex/packages/app-server-daemon 关闭该标志后,新的 TUI 会话不再生成守护进程。 相关:[#40969](https://github.com/openai/codex/issues/40969)、[#41188](https://github.com/openai/codex/issues/41188)、[#46468](https://github.com/openai/codex/issues/46468)、[#48050](https://github.com/openai/codex/issues/48050)、[#42457](https://github.com/openai/codex/issues/42457)、[#37537](https://github.com/openai/codex/issues/37537) ## 正文 · 原文 ### What variant of Codex are you using? CLI — 0.157.0, installed via `npm install -g @openai/codex`, Linux (WSL2) ### What feature would you like to see? Please make `daemon_auto_start` **opt-in (default `false`) for the CLI**, or at least ask once before turning it on. Since 0.157.0, just opening an interactive `codex` session: 1. **Starts a persistent background daemon** (`codex app-server --managed-daemon`). It runs in its own session with no TTY and keeps running after every Codex window is closed (reparented to PID 1) until `codex app-server daemon stop` or a reboot. 2. **Copies the whole platform package** (~374 MB: `codex`, `codex-code-mode-host`, bundled `bwrap`/`zsh`/`rg`) into `~/.codex/packages/app-server-daemon/releases//` — byte-identical to what npm had just installed — and runs the daemon from that copy. From then on the backend's version is decoupled from the CLI version I installed with my package manager. 3. **Starts a detached updater** (`codex app-server daemon pid-update-loop`) that checks for updates 5 minutes after start and then hourly, downloads new releases and restarts the backend (which can kill active turns, see [app-server daemon: auto-update force-kills active turns after a 60s drain budget, and cannot be disabled #40969](https://github.com/openai/codex/issues/40969)). 4. **Pins the environment of whichever session happened to start it.** I launch Codex through a wrapper that sets `HTTPS_PROXY` per invocation; the daemon keeps the first session's proxy variables and its outbound connections go through that proxy, whatever later sessions are launched with. [Hooks in --remote mode receive the daemon's cwd, not the session's #42457](https://github.com/openai/codex/issues/42457) and [Hooks spawned by the app-server daemon cannot identify the client terminal, breaking terminal-targeting hooks #37537](https://github.com/openai/codex/issues/37537) (daemon cwd / terminal instead of the session's) look like the same root cause. For a CLI, 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. A shared, self-updating daemon makes sense for Remote Control / the desktop app, so it would be fine to enable it there, or when the user explicitly runs `codex app-server daemon start` / `bootstrap`. If it stays on by default, please at least: - exit an auto-started daemon when its last client disconnects; - not copy/self-update when the CLI was installed by a package manager (npm/brew/pacman) — run the installed binary instead ([Support externally managed app-server daemon executables #41188](https://github.com/openai/codex/issues/41188), [npm update leaves app-server on old version, but daemon update/restart refuse recovery #46468](https://github.com/openai/codex/issues/46468), [Codex 0.157.0 no longer starts with the Arch Linux package unless --no-daemon is used #48050](https://github.com/openai/codex/issues/48050)). ### Additional information **Bug found while turning it off:** `codex app-server daemon stop` stops the app-server but leaves the `pid-update-loop` updater running (still alive 70 s later, had to kill it manually). Workaround I'm using: codex features disable daemon\_auto\_start codex app-server daemon stop pkill -f 'app-server daemon pid-update-loop' # not stopped by \`daemon stop\` rm -rf ~/.codex/packages/app-server-daemon With the flag off, a new TUI session no longer spawns a daemon. Related: [#40969](https://github.com/openai/codex/issues/40969), [#41188](https://github.com/openai/codex/issues/41188), [#46468](https://github.com/openai/codex/issues/46468), [#48050](https://github.com/openai/codex/issues/48050), [#42457](https://github.com/openai/codex/issues/42457), [#37537](https://github.com/openai/codex/issues/37537)