Skip to content

Windows: shared daemon keeps its first launcher's environment for every later session, and daemon_auto_start=false still attaches to a running daemon #48778

Closed as not planned

Description

@flawiddsouza

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:

  1. Make sure no daemon is running: codex app-server daemon stop.
  2. From a shell, set MY_MARKER=from-first-launcher then run codex. Exit codex. The daemon stays up.
  3. From a different terminal without MY_MARKER, run codex and ask it to run cmd /c echo %MY_MARKER% (or echo $env:MY_MARKER).
  4. The command prints from-first-launcher.

Problem 2:

  1. With a daemon running, add [features] daemon_auto_start = false to config.toml (or codex features disable daemon_auto_start).
  2. Run codex. The process tree shows the new session attached to the existing daemon (the codex.exe app-server --listen unix:// --managed-daemon process spawns its tool processes), and the Windows console popups from the linked issues continue.
  3. Run codex --no-daemon instead. 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 = false should 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-daemon provided.

Additional information

Activity

  1. added
    bug
    CLI
    windows-os
    app-server
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIapp-serverbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions