Windows: codex-code-mode-host opens a visible Windows Terminal window #37599
Description
What version of Codex CLI is running?
@openai/codex 0.147.0 (current npm latest at the time of filing).
Also observed while Codex Desktop 26.803.5235.0 was installed, but the visible window captured in this report identified the global npm package path, not the protected WindowsApps package path.
Subscription and model
This appears independent of subscription and model. It occurs when a local Code Mode tool call causes the standalone host process to be spawned.
Platform
- Windows 11 x64
- Version
10.0.26200, build26200 - Windows Terminal configured as the default terminal application
What issue are you seeing?
When the standalone Code Mode host is started from the Windows npm package, Windows Terminal opens a visible window whose command is the packaged console executable:
%APPDATA%\npm\node_modules\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex-code-mode-host.exe
The window can remain open and requires manual closing. A live process/window capture correlated the following components in the same creation-time cluster:
codex.exe
-> codex-code-mode-host.exe
-> conhost.exe
OpenConsole.exe / WindowsTerminal.exe -> visible terminal window
The packaged codex-code-mode-host.exe is PE subsystem 3 (IMAGE_SUBSYSTEM_WINDOWS_CUI).
The current source starts the host in codex-rs/code-mode/src/remote_session/connection.rs, Connection::spawn():
codex/codex-rs/code-mode/src/remote_session/connection.rs
Lines 213 to 224 in 3aae5d8
| impl Connection { | |
| pub(super) async fn spawn(host_program: &Path) -> Result<Self, ConnectionError> { | |
| let mut command = Command::new(host_program); | |
| #[cfg(unix)] | |
| command.process_group(0); | |
| let mut child = command | |
| .stdin(Stdio::piped()) | |
| .stdout(Stdio::piped()) | |
| .stderr(Stdio::piped()) | |
| .kill_on_drop(true) | |
| .spawn() | |
| .map_err(|error| ConnectionError::Spawn { |
The command configures Unix process groups, stdio pipes, and kill_on_drop, but has no Windows creation flag before .spawn():
let mut command = Command::new(host_program);
#[cfg(unix)]
command.process_group(0);
let mut child = command
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.kill_on_drop(true)
.spawn()?;Because the parent is a GUI/headless process and the child is a Windows console-subsystem executable, Windows can allocate the configured default terminal for it.
Steps to reproduce
- Install
@openai/codex@0.147.0globally on Windows. - Configure Windows Terminal as the default terminal application.
- Start a Codex session that uses local Code Mode.
- Invoke a local Code Mode tool so the standalone host is created.
- Observe a visible Windows Terminal window whose command is
codex-code-mode-host.exe.
This may be easier to reproduce after terminating an existing long-lived host so the next tool call must create a fresh one.
Expected behavior
codex-code-mode-host.exe should run as an internal background helper without creating a visible terminal window or stealing focus. Its stdin/stdout/stderr protocol and exit behavior must remain unchanged.
Root-cause hypothesis and validated mitigation
A local proof of concept placed a Windows GUI-subsystem shim at the expected host path and retained the signed vendor binary as codex-code-mode-host.real.exe. The shim:
- forwards all arguments;
- inherits stdin, stdout, and stderr;
- starts the real host with
CREATE_NO_WINDOW; - waits for it and returns the same exit code.
Validation results:
shim -> codex-code-mode-host.real.exe: confirmed
stdin/stdout round trip: passed
exit-code propagation: passed
real host startup and EOF shutdown: passed
visible host Terminal windows: 0
Before the mitigation, the visible Terminal window identified codex-code-mode-host.exe. After forcing a fresh host start through the shim, no matching visible window was created.
The binary-replacement shim is only a diagnostic mitigation and is not proposed as the product fix. It is update-fragile and changes the packaged executable identity.
Suggested product fix
In Connection::spawn(), apply CREATE_NO_WINDOW (or the equivalent supported Tokio/Windows process option) to the host command on Windows before .spawn(), while preserving the existing pipe and lifecycle behavior.
Conceptually:
let mut command = Command::new(host_program);
#[cfg(unix)]
command.process_group(0);
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW);A Windows regression test should verify both protocol behavior and absence of an allocated visible console for a freshly spawned host.
Related but not duplicate
- Windows: hide command-safety PowerShell parser process to avoid pwsh.exe console flashes #18984 tracks the command-safety PowerShell parser console flash.
codex execon Windows spawns a visible long-lived PowerShell helper window when launched headlessly #20510 tracks the long-lived PowerShell helper spawned by backgroundcodex exec.- [bug] Computer Use helper's black console briefly appears when a turn completes #33254 tracks the Computer Use turn-ended notifier console window.
Those issues involve different child executables. This report is specifically about the standalone codex-code-mode-host.exe spawn boundary.
Activity
github-actions commentedon Aug 8, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
wstczyw commentedon Aug 8, 2026
Thanks for the duplicate check. I reviewed both candidates; this appears related, but not a duplicate.
powershell.exeAST safety parser spawned from the command-safety layer. This report concerns the separatecodex-code-mode-host.exeprocess, spawned byConnection::spawn()incodex-rs/code-mode/src/remote_session/connection.rs.codex-code-mode-host.exeor this spawn site.The executable, lifetime/protocol, and source boundary are different. A fix limited to the PowerShell parser spawn in #36560 would not affect the Code Mode host spawn. Conversely, the proposed
CREATE_NO_WINDOWchange here belongs on the standalone hostCommandinConnection::spawn().I am therefore leaving #37599 open as the precise Code Mode host case. It can be cross-linked with #37153 as one concrete cause of that broader symptom.
wstczyw commentedon Aug 10, 2026
Corrected follow-up: below is the final acceptance evidence for the Codex Desktop-version-matched CLI build used to reproduce and mitigate #37599.
Exact version and source provenance
26.803.5235.0codex-cli 0.147.0-alpha.6.5codex-cli 0.147.0-alpha.6.5rust-v0.147.0-alpha.6.5, resolving to commit618b8e9The patch's three preimage blob IDs match that tag exactly:
codex-rs/code-mode/src/remote_session/connection.rs:d08c8fbbc448...codex-rs/shell-command/src/command_safety/powershell_parser.rs:00b18af6f053...codex-rs/shell-command/src/powershell.rs:9730439bea31...#37599-specific patch
The relevant Code Mode Host change is:
The end-to-end validation patch also routes the long-lived PowerShell parser and PowerShell discovery probes through the existing Windows no-console helper. Those companion changes remove separate PowerShell popup surfaces; they are not being presented as the root fix for #37599.
The build was installed in an external versioned directory and selected through the supported
CODEX_CLI_PATHoverride. No file under the signed/protected WindowsApps package was modified. The deployedcodex-code-mode-host.exeis byte-for-byte identical to the Desktop-packaged host:Validation
The original build/acceptance run passed the focused Rust tests for the affected Code Mode and PowerShell launch paths, the release build, an App Server handshake, and five bounded top-level Windows Terminal observations.
After a full Desktop restart, I repeated the runtime read-back:
codex.exe -> codex-code-mode-host.exe;initializehandshake returned successfully, exited0, and produced no stderr;This is a validated local mitigation, not a claim that upstream is fixed. As of current
maincommit355ee6c,Connection::spawn()still has no Windows creation flag, so #37599 should remain open.bhill298 commentedon Sep 21, 2026
I've seen this on Windows x64 using standalone Codex CLI 0.155.0 and 0.155.1, with the native local app-server daemon and local TUI without
--remote.The Code Mode host
CREATE_NO_WINDOWfix already demonstrated in this issue worked when I applied it on my end. I used the release source, matching PDBs, and disassembly to apply edits to the parent CLI binary. The code-mode host binary itself was unchanged. The broader daemon workload also showed that there were separate launch sites. The initial helper edits removed the persistent windows, but brief flashes remained. A trace then identified frequent Git console events, covering the captured Git/job path and its fallback eliminated Git show events in the next capture. The remaining events coincided with short computer-use helper launches. Adding no-window to the legacy notification launcher eliminated the remaining observed flashes, which is discussed in #33254.The important implementation detail for the related background paths is flag replacement. The shared job helper sets
CREATE_SUSPENDED, while Git fallback resets creation flags to zero. A no-window flag set only at construction is therefore lost. The intended final flags areCREATE_NO_WINDOW | CREATE_SUSPENDEDfor contained startup andCREATE_NO_WINDOWfor an unsuspended fallback, preserving job assignment/resume and process cleanup. This should be limited to noninteractive callers, and it should not be imposed on interactive TUI/ConPTY launches.After all of the edits, I saw no flashes during ordinary messages or a broader tool workload. Two traces totaling about 180 seconds recorded zero console show events. There was one invisible pseudo-console creation during interactive terminal testing. The workload included concurrent shell/Git/Node/Python activity, Node REPL restart, large stdout/stderr output, nonzero exits, child cancellation, and interactive terminal I/O.
The attached python script demonstrates the underlying Windows behavior. From a detached parent, the original flags allocate a console. Setting no-window only initially still fails the suspended/fallback cases. Preserving it passes all four cases.
Source references from commit 88ef37c:
yehsuf commentedon Sep 23, 2026
Still reproducible on Windows with Codex CLI 0.156.0 and the 0.156.1 app-server daemon (2026-09-23). I launch the CLI from PowerShell. A visible console window is titled
%USERPROFILE%\.codex\packages\app-server-daemon\releases\0.156.1-x86_64-pc-windows-msvc\bin\codex-code-mode-host.exe; process inspection showed this host was started by the nativecodex.exeapp-server daemon.Changing Windows' default terminal application from Windows Terminal to Windows Console Host changed the window's appearance but did not suppress it. In an isolated test, starting Codex with
--disable code_mode_hoststopped the host window from appearing, but a simple request to list one file failed because the command tool returnedcode-mode host is disabled. Thus that flag is not a functional workaround.This confirms the issue also affects the app-server-daemon packaged host in 0.156.1. Please launch the host without allocating a visible console while preserving its stdio protocol.
loveu8 commentedon Sep 25, 2026
Additional reproduction on 2026-09-25; this remains present in Codex CLI 0.157.0 and the matching managed app-server daemon.
Environment:
0.157.0, started in Git Bash inside Windows Terminal.1.24.11911.0; Git Bash is the default Terminal profile.[windows] sandbox = "elevated";code_mode_hostis enabled (the CLI reports it as a stable, enabled feature).%USERPROFILE%\.codex\packages\app-server-daemon\releases\0.157.0-x86_64-pc-windows-msvc\bin\codex-code-mode-host.exe.Observed:
.codex\packagespath.codex-code-mode-host.exeat the managed-daemon path above.Expected: the local Code Mode host runs without any visible tab/window or focus theft. Switching terminal hosts is not a workaround. Screenshots of both presentations are available if useful.
getupkid commentedon Sep 25, 2026
I’m seeing the same issue from @loveu8 on Windows 11 Pro with Codex CLI 0.157.0.
In my case it’s much more disruptive than a single popup at startup:
codex doctorreports the background app-server as not running (ephemeral mode), so this does not appear to be caused by a persistent daemon.This only started for me after updating to 0.157.0; I did not experience this behavior on the previous version I was using.
The symptoms seem consistent with codex-code-mode-host.exe being spawned without CREATE_NO_WINDOW on Windows, particularly when file search / local tool functionality is invoked.
At the moment this makes 0.157.0 effectively unusable for normal interactive CLI work on Windows.
ofek commentedon Sep 25, 2026
This also is now happening to me after upgrading the Codex CLI from
0.156.1to0.157.0but with a different internal binary.C:\Users\ofek\AppData\Local\OpenAI\Codex\runtimes\cua_node\13827bafdc0b5422\bin\node_repl.exe:2026-09-25.01-13-29.mp4
TechDudie commentedon Sep 25, 2026
Occurs now after upgrading to 0.157.0
20260925-0621-55.1608326.mp4
wikes82 commentedon Sep 25, 2026
I'm getting this now after updating to 0.157.0
I noticed this only happening if I launch Codex CLI on a git repo folder .. if the folder is not a git repo, it doesn't flash any terminal/cmd windows
per-johansson-74 commentedon Sep 25, 2026
it does also open a permanent codex-code-mode-host.exe window in 0.157.0
I found a workaround that makes codex not flash windows all the time kill all codex processes then start with
codex --no-daemon2 remaining items
getupkid commentedon Sep 25, 2026
Its looks like running
codex --no-daemoncould be a potential workaround until this gets fixed as mentioned here #46949 (comment). It's not perfect but at least it's somewhat usable now.MLJ0422 commentedon Sep 25, 2026
Additional confirmation for the 0.157.0 managed per-user runtime: the host at
%USERPROFILE%\.codex\packages\app-server-daemon\releases\0.157.0-x86_64-pc-windows-msvc\bin\codex-code-mode-host.exeis PE subsystem 3 (Windows Console). Process capture showscodex.exe app-server --listen unix:// --managed-daemon→codex-code-mode-host.exe→conhost.exe. The visible-terminal symptom is present in this environment; no host crash was observed. Installed VS Code extension version: 26.917.62051.etraut-openai commentedon Sep 25, 2026
Thanks for the bug reports. This will be addressed in an upcoming release. In the meantime,
codex --no-daemonshould work around the problem.ofek commentedon Sep 25, 2026
@zm-oai @etraut-openai Thanks! Could you please link the PR/commit so that I'd be able to test? The cause of my issue is slightly different so I want to be sure.
Kir-STR commentedon Sep 25, 2026
Additional data point on Windows, npm-installed CLI 0.157.0 + app-server daemon 0.157.0.
Visible console windows appear during requests for node.exe, node_repl.exe, cmd.exe and codex-code-mode-host.exe — some flash, some persist. So in 0.157.0 this isn't limited to the code-mode host.
Same machine, same projects:
--no-daemon(also tried with--sandbox read-only): no unwanted windowsReboot, daemon restart, reinstalling 0.157.0 and
app-server daemon update --from-clidid not help. In my case the daemon path in 0.157.0 is what triggers it, though @getupkid reports windows without a running daemon, so there may be more than one launch path involved. Currently staying on 0.156.0.wikes82 commentedon Sep 26, 2026
issue still persists on latest 0.157.1, why is this issue closed?
per-johansson-74 commentedon Sep 26, 2026
I updated to 0.157.1 also updated the daemon with the /daemon command in codex and confirmed it now runs 0.157.1
Result: The extra permanent daemon terminal window is now gone. But codex still opens/closes a lot of terminal windows when doing anything. like !git status for example.
So starting with codex --no-daemon still is required for it to be usable
GabGodz commentedon Sep 26, 2026
fix this shit
getupkid commentedon Sep 26, 2026
Downgrading to 0.156.1 was the only plausible solution for me.
natansalvadorligabo commentedon Sep 26, 2026
same here
DataScienceLondon commentedon Sep 26, 2026
Confirming this affects my Windows Codex CLI 0.157.0 installation as well. The extra terminal windows appear while Codex is working, across different folders (including outside any particular project), and repeatedly steal focus, making it difficult to use other Windows applications during a task. Please prioritize a fix or provide a clear user-facing workaround. I understand
codex --no-daemonhas been suggested in this thread; the default behavior remains disruptive.RycqA commentedon Sep 27, 2026
I can reproduce a very similar issue on Windows 11 with Codex CLI 0.156.0.
Environment:
Symptoms on 0.156.0:
Minimal reproduction:
"Do not modify any files. Run
git status --shortonce and return only the result."I captured the process with Process Monitor. The short-lived process was:
powershell.exe -NoProfile -Command "try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}
git --no-optional-locks status --short"
The process ran as:
DESKTOP-...\CodexSandboxOffline
So this is reproducible without Orca and appears to come from Codex's Windows sandbox/shell execution path.
I also tested a rollback:
0.156.0:
0.155.0:
So rolling back to 0.155.0 removes the most disruptive focus-stealing behavior, but the visible console flash still remains.
This makes it difficult to use Codex in the background while working in another application.
Expected behavior:
Non-interactive shell/tool child processes should run without creating a visible console window and must not steal foreground focus.
If useful, I can provide the Process Monitor capture and additional process-tree information.
GabGodz commentedon Sep 27, 2026
why it keep closed, is impossible to work with codex since i cant even use my pc while codex is being used with 10+ agents using powershell commands rly interisting how a big company can push updates without check accessibility for all platforms MAINLY Windows, is frustrating theses few days even with codex --no-daemon the session is not persistent, it only persists within the created window, so, if my limit runs out and i need to continue with another account in the same session this problem persists cuz is other window.
Masterxilo commentedon Sep 29, 2026
I see it flashing console Windows all the time now.