Skip to content

The Codex desktop app's execution service (codex-code-mode-host.exe) exits during handshake, so every exec tool call fails. The error is intermittent but frequent.bug #40899

Open

Description

@c296274227-oss

codex_bug_report.md

Bug Report: "code-mode host exited during handshake"

Summary

The Codex desktop app's execution service (codex-code-mode-host.exe) exits during handshake, so every exec tool call fails. The error is intermittent but frequent.

Error message

error=code-mode host exited during handshake
target=codex_core::tools::router

Environment

  • App: ChatGPT desktop app (Codex) — OpenAI.Codex_26.820.7780.0_x64__2p2nqsd0c76g0
  • Bundled CLI: codex-cli 0.150.0-alpha.8 (windows-x86_64)
  • OS: Windows 10 (10.0.19045, build 19045.6466), Chinese locale, ANSI code page 936 (GBK)
  • Model: gpt-5.6-terra / gpt-5.6-sol

When it started

Immediately after the auto-update on 2026-08-26 (~17:47 local time), which bumped the bundled CLI from 0.149.0-alpha.4.x to 0.150.0-alpha.8. No such errors before the update.

Repro steps

  1. Open the Codex desktop app.
  2. Start any task that triggers the exec tool (e.g. "run echo hello").
  3. The exec tool call fails with code-mode host exited during handshake; the model retries and fails repeatedly.

Key observations

  • The error is intermittent: some exec calls succeed, then a cluster of failures follows.
  • It reproduces in both ASCII and non-ASCII working directories (so it is not path/encoding specific).
  • No crash dump or WER report is generated for codex-code-mode-host.exe — the host exits cleanly, so this is a handshake/protocol failure, not a crash.
  • Running codex-code-mode-host.exe manually works; it starts and waits for the client hello.
  • Disabling the feature code_mode_host makes exec fail closed (the model cannot run commands at all), so that is not a viable workaround.
  • codex doctor reports: search command not verified, and a generic Microsoft Defender advisory (exclusions were added but did not resolve the issue).

Impact

All exec-based work (running commands, Python, spreadsheet/document artifact creation, etc.) is blocked intermittently in the desktop app. The older VS Code extension CLI (0.147.0-alpha.6.5) does NOT have this problem.

Log excerpt

codex_core::tools::router (core\src\tools\router.rs:225)
... dispatch_tool_call_with_code_mode_result{otel.name=exec tool_name=exec ...}:dispatch_tool_call_with_terminal_outcome: error=code-mode host exited during handshake

Activity

  1. changed the title [-]The Codex desktop app's execution service (`codex-code-mode-host.exe`) exits during handshake, so every `exec` tool call fails. The error is intermittent but frequent[/-] [+]The Codex desktop app's execution service (`codex-code-mode-host.exe`) exits during handshake, so every `exec` tool call fails. The error is intermittent but frequent.bug[/+] on Aug 26, 2026
  2. CloudyRiver9 commented on Aug 26, 2026

    @CloudyRiver9

    Related Windows Desktop report with additional diagnostics: #40913

    Key extra finding there: from the ChatGPT Desktop process context, spawning the bundled runtime fails at the lowest level:

    C:\Users\c\AppData\Local\OpenAI\Codex\runtimes\cua_node\950613ca46815e82\bin\node.exe --version
    nodeVersionError.code = 3221225506  (0xC0000022)
    

    while the exact same node.exe launched manually from PowerShell succeeds (v24.19.0, exit 0). A full clean-room reset of all Codex/Desktop state, reinstall, disabling code_mode_host, Defender exclusions, and stopping Nahimic did not change the result. The main Desktop -> codex app-server stdio handshake succeeds; only the local code-mode execution child-chain fails. This points to the Desktop/MSIX packaged child-process context rather than the binaries or user state.

  3. wangzongshuji commented on Aug 27, 2026

    @wangzongshuji

    How to solve? I have tried various methods, but none of them have solved the problem

  4. CloudyRiver9 commented on Aug 27, 2026

    @CloudyRiver9

    用旧版本吧,我在找了

  5. CloudyRiver9 commented on Aug 27, 2026

    @CloudyRiver9

    换了beta版本。能用了

  6. karumeno commented on Sep 1, 2026

    @karumeno

    A workaround that fixed this on my Windows machine:

    Check this registry value:

    HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SafeDllSearchMode
    

    If it is 0, set it back to 1, then fully quit and restart Codex Desktop.

    Administrator PowerShell:

    reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v SafeDllSearchMode
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v SafeDllSearchMode /t REG_DWORD /d 1 /f

    After doing this, code-mode host exited during handshake disappeared for me and GPT-5.6 local tool execution worked again.

    This matches the likely 0xC0000022 / dbghelp.dll path discussed in #40798. It is not an official fix, but it restored the Windows default Safe DLL Search Mode rather than weakening security.

  7. alifarhan1223-rgb commented on Sep 18, 2026

    @alifarhan1223-rgb

    I am experiencing the same issue on Windows.

    Feedback ID: 01a0b47a-7b4c-7ca2-ab88-24407dddc84c

    Environment

    • Windows 11 build: 26200.9457
    • Codex Desktop: 26.915.3509.0
    • Bundled Codex CLI: 0.155.0-alpha.9
    • ChatGPT Plus

    Observed behavior
    Desktop Work/Codex local workspace tools consistently fail before execution with:

    code-mode host exited during handshake

    I reproduced this across multiple fresh tasks and with GPT-5.6 Sol, GPT-5.5, and Astra.

    Important isolation result
    The bundled codex.exe CLI works successfully on the same machine.

    Using codex.exe exec --ephemeral --skip-git-repo-check, Codex successfully invoked PowerShell and executed a read-only directory listing of:

    C:\Users\alifa\Documents\Codex\2026-09-18

    So local filesystem access, PowerShell execution, authentication, networking, and the Codex CLI itself are working.

    Codex Doctor
    Healthy:

    • config
    • auth
    • network/WebSocket
    • sandbox provisioning
    • state databases
    • desktop installation

    Warnings:

    • Microsoft Defender advisory
    • rg.exe search binary not verified
    • optional MCP warning: CODEX_WINDOWS_REGISTERED_CORE is not set

    I have not manually modified that environment variable.

    I also verified that the configured paths for node_repl.exe, codex.exe, codex-code-mode-host.exe, and codex-command-runner.exe match the currently installed binaries.

    This appears to be specific to the Windows Desktop code-mode host / local-tool integration layer rather than the CLI or filesystem.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions