openai / openai/codex

[Windows] Codex CLI exits/crashes while running commands that complete normally outside Codex

Open
#42,512 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI sandbox tool-calls windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

codex-cli 0.153.0

What subscription do you have?

ChatGPT Pro

Which model were you using?

gpt-5.6-sol max

What platform is your computer?

Microsoft Windows 11 Pro Version: 10.0.26200 Build: 26200 Architecture: 64-bit / x64

What terminal emulator and version are you using (if applicable)?

VS Code integrated terminal using PowerShell (version 1.136.0)

Codex doctor report
codex doctor --json completes successfully.

Overall status: warning

Important results:
- Codex CLI: 0.153.0
- Installation: OK / consistent
- Install method: Windows standalone
- Runtime: windows-x86_64
- Authentication: OK
- Config: loads successfully
- Network provider reachability: OK
- Responses WebSocket handshake: OK
- Sandbox configuration: readable
- State databases: all reported integrity OK
- Thread history database integrity: OK
- Disk space: OK (~1743.6 GiB available)
- Codex is already on the latest detected version (0.153.0)

The only notable warning is Microsoft Defender:
"endpoint protection detected; Codex exclusions are unverified"

The doctor suggests that Microsoft Defender could potentially interfere with Codex helpers, but it does not report an installation, database, network, authentication, or sandbox configuration failure.
What issue are you seeing?

Codex CLI unexpectedly stops/exits during shell tool execution on Windows.

The issue is especially reproducible when Codex runs a Python unittest suite. Codex starts the command, but during execution the TUI unexpectedly stops/exits back to PowerShell.

The exact same Python executable and exact same unittest command complete normally when I run them manually from PowerShell in the same project directory.

This strongly suggests that the failure occurs in Codex's Windows command/tool execution layer rather than in Python, Anaconda, the tests, or the machine itself.

I also experienced repeated Windows elevated sandbox setup prompts. Manual elevated sandbox setup succeeds, but Codex can later request setup again. Switching to the non-admin/unelevated sandbox does not resolve the command-execution crash.

What steps can reproduce the bug?
  1. Start Codex CLI 0.153.0 on Windows 11 from PowerShell inside the project directory.

  2. Ask Codex to run the following Python unittest suite:

C:\ProgramData\anaconda3\python.exe -m unittest tmp.test_base_agent_import tmp.test_component_classification_contract tmp.test_component_discovery_recovery tmp.test_component_fit tmp.test_component_need_engineering tmp.test_component_recommender_sources tmp.test_component_search_qualification tmp.test_datasheet_extraction_isolation tmp.test_datasheet_voltage_scope tmp.test_layer_agreement_fixes tmp.test_mostafa2_generator tmp.test_relationship_stage1_contracts tmp.test_topology_end_to_end_matrix

  1. Codex begins executing the command.

  2. During execution, Codex unexpectedly stops/exits instead of waiting for the command to finish and returning its output.

  3. Open/use PowerShell in the exact same project directory.

  4. Run the exact same command manually with the exact same Python executable.

  5. The unittest command completes normally outside Codex.

The issue has also reproduced after completely removing Codex and its local state and performing a fresh standalone installation of Codex CLI 0.153.0.

It reproduces with the unelevated/non-admin sandbox and was also observed while troubleshooting the elevated/default sandbox.

What is the expected behavior?

Codex should start the unittest process, remain running while the process executes, collect its stdout/stderr and exit code, and then continue the conversation normally.

Since the exact same command completes successfully when launched manually from PowerShell, Codex should also be able to execute and collect the result without the CLI stopping or exiting.

Additional information

I performed extensive troubleshooting before reporting this:

  • Restarted Windows.

  • Completely uninstalled Codex.

  • Removed the entire previous .codex directory.

  • Removed previous sessions, thread databases, logs, sandbox state, configuration, caches, and previous runtime state.

  • Installed Codex again from scratch using the Windows standalone installer.

  • The fresh installation is Codex CLI 0.153.0.

  • The problem still reproduces after the clean installation.

  • Tested the default/elevated Windows sandbox.

  • Tested the non-admin/unelevated Windows sandbox.

  • The execution problem still occurs.

  • Manual elevated sandbox setup succeeds with:

    codex sandbox setup --elevated --current-user --codex-home "$env:USERPROFILE.codex"

    and returns:

    Windows elevated sandbox setup completed for zeyad at C:\Users\zeyad.codex.

  • Despite this, the elevated sandbox may later request setup again.

  • Most importantly, the exact Python unittest command that causes Codex to stop completes successfully when executed manually from PowerShell on the same machine, in the same working directory, using the same Python executable.

The same general Codex execution/crash problem was also occurring before the clean reinstall.

One potentially relevant data point from codex doctor is the Microsoft Defender warning. Defender is installed and Codex could not verify exclusions for codex.exe and its helper executables. I have not disabled Microsoft Defender. However, the underlying Python command itself runs successfully outside Codex.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the exact unittest command from PowerShell through Codex CLI 0.153.0 on Windows 11, comparing behavior in the elevated and unelevated sandboxes; review the Windows shell/tool execution path and the codex doctor output, including the Defender warning. Done means Codex remains running, captures stdout/stderr and exit code, and continues normally after the command completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, python, rust
Domain
cli, operating-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.