Skip to content

Exit when the Codex process dies - #359

Open
jmeyers91 wants to merge 1 commit into
agentclientprotocol:mainfrom
jmeyers91:fix/exit-on-backend-death
Open

Exit when the Codex process dies#359
jmeyers91 wants to merge 1 commit into
agentclientprotocol:mainfrom
jmeyers91:fix/exit-on-backend-death

Conversation

@jmeyers91

Copy link
Copy Markdown

Summary

  • exit(1) when the spawned Codex app-server process dies (child exit or stdout EOF) instead of keeping the ACP connection open
  • previously nothing was pushed to the client and in-flight requests (session/prompt, a login waiting on its completion) hung forever; only the next request failed, with a generic "Connection is disposed"
  • exiting surfaces the death as stdio EOF, which rejects in-flight requests at the transport layer and lets the client restart the agent
  • a diagnostic line (exit code, recent codex stderr, the VC++ hint for 3221225781) is written to stderr first, so clients that surface an exited agent's stderr still show the cause — the startup-crash diagnostics that runWithProcessCheck delivers lazily, including the missing-VC++-redistributable case, stay visible
  • client-initiated shutdown (stdin close) keeps its existing behaviour; login/cli subcommands are untouched
  • stdout end is watched as well as exit because the win32 spawn goes through a shell, so the child handle can outlive the real codex process
  • happy to rework toward an in-band error or respawn design instead if that's preferred

Testing

  • npm run typecheck
  • npm test (340 passed, 29 skipped)
  • new acp-e2e-backend-death.test.ts (POSIX-only): SIGKILLs the codex app-server under a spawned agent, asserts the agent exits within 5s — fails on main, passes with this change; run locally like the other e2e specs
  • standalone reproduction (no test framework, sandboxed CODEX_HOME, fake key, local tarpit for the model call): https://github.com/jmeyers91/codex-acp-backend-death-repronpm run repro shows the hang on published 1.1.9; ADAPTER_ENTRY=path/to/dist/index.js node repro.mjs shows the fix
  • verified on macOS arm64 and Windows x64, on both the bundled backend and the CODEX_PATH route

@jmeyers91
jmeyers91 force-pushed the fix/exit-on-backend-death branch from 674a8e6 to 56ed8bc Compare August 3, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant