Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.157.1 (npm), managed daemon package 0.157.1-x86_64-pc-windows-msvc
What subscription do you have?
n/a
Which model were you using?
gpt-6-sol
What platform is your computer?
Windows 11 Pro 10.0.22631
What terminal emulator and version are you using (if applicable)?
Codex was launched inside a ConPTY by a session-management tool (a Go program driving codex through a pseudoconsole). Later sessions were plain Windows Terminal.
Codex doctor report
Codex Doctor v0.157.1 · windows-x86_64
✓ runtime npm, version 0.157.1, executable ...\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe
✓ install consistent
⚠ sandbox filesystem unrestricted · network enabled
What issue are you seeing?
Two related problems with the shared app-server daemon on Windows. The console popups themselves are already tracked in #44768, #48440, #48422 and #48356, so this report is about the two things those don't cover.
1. The daemon permanently keeps the environment of whichever process first launched it, and hands it to every later session.
daemon_auto_start is on by default in 0.157.1, so the first interactive codex launch after the update installs and starts the daemon. In my case that first launch happened inside a tool that runs codex in a ConPTY and marks the environment of everything it starts (a *_THREAD_ID variable, a daemon-directory variable). The daemon is spawned with DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB (app-server-daemon/src/backend/pid_start.rs) and the launcher's full environment. It escaped the launcher's job, the launcher exited, and the daemon lived on.
Reading the daemon's environment block confirms it still carries the launcher's marker variables. Since every later codex session from any terminal attaches to this daemon, every shell command those sessions run, and every MCP server the daemon starts, now inherits the first launcher's environment instead of the environment of the terminal the user actually typed codex in. In my case that made the launching tool believe those later processes were running inside one of its own sessions.
Expected: the daemon should either start with a minimal environment, or per-session process spawns should use the attaching client's environment, not the daemon's.
2. daemon_auto_start = false does not stop Codex from using a daemon that is already running.
In tui/src/startup_orchestration.rs, auto_start_daemon honors Feature::DaemonAutoStart, but reuse_implicit_local_daemon = daemon_exclusion.is_none() does not. daemon_startup::exclusion only considers --no-daemon, --oss, --profile, overrides and so on. So with the feature disabled in config.toml, maybe_probe_default_daemon_socket still finds a live socket and the TUI attaches with allow_embedded_fallback: true.
Result: a user who disables the feature to avoid the Windows console popups still gets them until they also find and run codex app-server daemon stop, and again the next time anything (an IDE, a script, codex app-server daemon start) brings a daemon up. Only the per-invocation --no-daemon flag actually guarantees embedded mode, which the --help text confirms ("even if it is already running").
What steps can reproduce the bug?
Problem 1:
- Make sure no daemon is running:
codex app-server daemon stop. - From a shell,
set MY_MARKER=from-first-launcherthen runcodex. Exit codex. The daemon stays up. - From a different terminal without
MY_MARKER, runcodexand ask it to runcmd /c echo %MY_MARKER%(orecho $env:MY_MARKER). - The command prints
from-first-launcher.
Problem 2:
- With a daemon running, add
[features] daemon_auto_start = falseto config.toml (orcodex features disable daemon_auto_start). - Run
codex. The process tree shows the new session attached to the existing daemon (thecodex.exe app-server --listen unix:// --managed-daemonprocess spawns its tool processes), and the Windows console popups from the linked issues continue. - Run
codex --no-daemoninstead. Everything runs embedded and the popups stop.
What is the expected behavior?
- A shared daemon should not pin one launcher's environment onto every future session.
daemon_auto_start = falseshould mean "do not use the shared daemon", including not attaching to one that already exists, or the feature should be documented as start-only and a config-level equivalent of--no-daemonprovided.
Additional information
core/src/spawn.rsspawn_child_asyncstill sets noCREATE_NO_WINDOWon Windows on currentmain, which is why a console-less daemon pops a window for every shell command. Mentioned only for cross-reference with Windows: app-server daemon opens a visible console window for every hook and shell command it runs #44768.- Verified the daemon has no console at all:
AttachConsole(daemon_pid)fails withERROR_INVALID_HANDLE, while the daemon's MCP children (spawned withCREATE_NO_WINDOWinrmcp-client) do have hidden consoles.
Activity
github-actions commentedon Sep 27, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
daemon_auto_startopt-in — a persistent, self-updating background daemon shouldn't be the default #48195Powered by Codex Action