Skip to content

Relaunch the Codex app-server automatically after an unexpected exit - #14

Merged
sadfun merged 1 commit into
sadfun:mainfrom
nocell:fix/codex-app-server-relaunch
Sep 19, 2026
Merged

sadfun merged 1 commit into
sadfun:mainfrom
nocell:fix/codex-app-server-relaunch

Conversation

@nocell

@nocell nocell commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Problem

When the Codex app-server child exits on its own — kernel OOM-killer, a stray kill -9, or a crash — Wirebot keeps running but only marks the runtime degraded. Every following turn fails with:

Codex app-server is unavailable: Codex app-server is not running. Runtime status: Codex app-server exited (SIGKILL). Send /wirebot restart to recover it.

and the bot stays unusable until a human sends /restart. Docker's restart: unless-stopped does not help because the Wirebot process itself never died.

Fix

CodexRuntimeService.handleExit now starts a background recovery loop for unexpected exits:

  • relaunch attempts run under the existing runtime serial lock with back-off 1s, 2s, 5s, 10s, 30s (about 50 seconds in total);
  • each attempt pauses turns, calls rpc.start() and the fresh-server reconcile, then resumes turns so a failed attempt yields an error instead of a hang;
  • a manual /restart or /reload that succeeds first ends the loop (checked via restartRequired), and stop() awaits an in-flight recovery;
  • once attempts are exhausted the current behaviour returns unchanged: degraded status with the manual-restart hint.

While a relaunch is in progress the runtime status text reads "the app-server is being relaunched automatically" instead of asking for /restart.

Expected exits (stop(), manual /restart) are untouched.

Verification

bun run check and bun test pass on Bun 1.4.0. No new tests, per maintainer request.

Docs

CHANGELOG [Unreleased] → Fixed and a short README paragraph next to the /restart description.

🤖 Generated with Claude Code

When the app-server child died on its own (OOM kill, a stray `kill -9`,
a crash), the runtime only flagged itself degraded and every turn failed
with "Codex app-server is not running … Send /restart to recover it"
until an operator noticed. Docker's restart policy does not help here
because the wirebot process itself keeps running.

CodexRuntimeService now reacts to an unexpected exit by relaunching the
server under the runtime lock with a short back-off (1s, 2s, 5s, 10s,
30s). Turns are paused during each attempt and resumed afterwards so a
failed attempt surfaces an error instead of hanging. A manual /restart
or reload that lands first ends the loop, and stop() waits for an
in-flight recovery. Once all attempts fail the previous behaviour
returns: degraded status with the manual-restart hint. The status text
shown while relaunching says so instead of asking for /restart.
@sadfun
sadfun merged commit 525ac16 into sadfun:main Sep 19, 2026
4 checks passed
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.

2 participants