Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.157.1 (npm install -g @openai/codex@latest, confirmed with codex --version)
What subscription do you have?
ChatGPT login. The CLI does not print the plan tier.
Which model were you using?
gpt-6-astra
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What terminal emulator and version are you using?
Cursor integrated terminal. Windows default console delegation was Automatic, so each new console was handed to Windows Terminal (CASCADIA_HOSTING_WINDOW_CLASS).
Codex doctor report
not included
What issue are you seeing?
This still happens on the latest CLI, and it happens for the whole session, not only at launch.
Every non-interactive shell command Codex runs (powershell.exe, cmd.exe, git.exe, and the command-safety PowerShell parser) allocates its own visible console. The window stays on screen until that command exits, so a multi-second command leaves a cmd/PowerShell window sitting on the desktop. Parallel tool calls open several at once. With the default terminal set to Automatic, Windows Terminal also opens a real window for the same process. The owner of that window is WindowsTerminal.exe under svchost.exe, so it is not a child of codex.exe.
Related open reports: #18984, #26613, #23856, #23892, #37599. Those cover the parser flash, background polling, and the code-mode host. This report is the session-long case on CLI 0.157.1, plus a workaround that was verified locally and the upstream change that removes the need for it.
What steps can reproduce the bug?
- On Windows 11, install
@openai/codex0.157.1 and leave the default terminal on Automatic. - Run
codexin a trusted repo and let it execute shell commands (git,rg,python,gh, or any PowerShell pipeline). - Watch the desktop while the turn is running, not only during process start.
What is the expected behavior?
Non-interactive children should keep piped stdin/stdout/stderr and should not create a visible console or a Windows Terminal window. An interactive codex session and any terminal the user opened themselves should stay visible.
Additional information
The elevated Windows sandbox path already passes CREATE_NO_WINDOW (windows-sandbox-rs CreateProcessWithLogonW). The normal shell, command-safety parser, hooks, and code-mode host spawns do not. -WindowStyle Hidden does not help: the console host is created before that argument runs. Hiding every CASCADIA_HOSTING_WINDOW_CLASS window is also unsafe, because those windows belong to WindowsTerminal.exe, not to Codex.
Proposed upstream fix
On every non-interactive Windows Command that already uses piped stdio, set CREATE_NO_WINDOW before spawn():
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW);Apply that in at least:
codex-rs/shell-command/src/command_safety/powershell_parser.rs(the long-lived AST parser)- the Windows shell exec path that launches
powershell.exe/cmd.exe/git.exefor a tool call - hook execution (
pwsh.exe -NoProfile -Command ...) Connection::spawn()forcodex-code-mode-host
Keep the existing pipes. Do not disable command-safety or shell execution. CREATE_NO_WINDOW still creates the console handles the child needs for redirected stdio; it only skips the visible window. A shared helper is better than one call site, because each of the issues above is a separate spawn.
Verified local workaround
Until that ships, two user-level changes stop the windows without wrapping Git or changing PATH:
-
Set the current-user console delegation to Windows Console Host so new consoles are not brokered to Windows Terminal:
- key:
HKCU\Console\%Startup DelegationConsoleandDelegationTerminal={B23D10C0-E52E-411E-9D5B-C09FDF709C7D}
Windows Terminal can still be opened manually. Existing Terminal windows stay open.
- key:
-
Run a small out-of-process guard. On
EVENT_OBJECT_SHOW/EVENT_OBJECT_CREATE, plus a 200ms scan, hide a top-level window only when all of the following are true:- class is
ConsoleWindowClassorPseudoConsoleWindow - the process ancestry contains a console launcher (
cmd.exe,powershell.exe,pwsh.exe,git.exe, or another tool Codex just spawned) and alsocodex.exeorChatGPT.exe - the nearest non-
conhostprocess is not the interactivecodex.exeitself
Leave a
conhost.exewhose only ancestor iscodex.exealone, and leave acmd.exethe user launched outside Codex. That distinction matters: a blanket hide of every console window also hides the user's own terminal. - class is
Checked on this machine after upgrading to CLI 0.157.1:
- a
cmd.exewhose parent wascodex.exeproduced no new visible window - a
cmd.exelaunched from the user session stayed visible (ConsoleWindowClass) - the guard log recorded the Codex child as
rule=CodexShelland did not record the user window
Activity
github-actions commentedon Sep 28, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
etraut-openai commentedon Sep 29, 2026
We're tracking this in #48074, and we're working on a fix.