Skip to content

[Bug]: Codex background command exiting mid-turn never triggers a continuation notice #44787

Not planned

Description

@yvesoddly

Before submitting

Area

apps/server

Steps to reproduce

  1. In a Codex thread, start a command with exec_command that outlives yield_time_ms, returning a running session ID to the model while the turn continues.
  2. Have the model keep doing other tool calls or reasoning in the same turn without polling that session again via write_stdin.
  3. Let the background command exit (e.g., fail with exit code 1) while that same turn is still active, before turn/completed.
  4. Let the model finish the turn assuming the job is still running in the background.

Expected behavior

Codex is woken with a "Background command completed..." continuation notice once the turn ends (or notified if a backgrounded exec_command exits without the model having observed its completion), so the agent does not end the turn believing a failed/finished job is still running.

Actual behavior

No continuation notice is ever sent. In apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts:

  • resolveItemEventContext(payload.turnId) (lines 2920–2929) returns settled: false because payload.turnId is still in activeTurns, not settledTurns.
  • The commandExecution completion handler (lines 6029–6115) clears the item from runningCommandItemsByTurn and emits turn_item.updated, then gates continuationRequests.offer(...) on if (settled) (line 6065).
  • Because settled is false, codexBackgroundCommandDetail is never queued, and once the turn ends the command is already gone from runningCommandItemsByTurn.

In practice, Codex receives the initial "running with session ID" response, the command fails with exit code 1 mid-turn, the model finishes its turn 40s later saying the job is still running, and the thread stays idle indefinitely until the user manually checks in.

Impact

Major bug (silent dropped background job failure / wedged workflow)

Version or commit

main @ db864d3 (upstream through aee6cf5)

Environment

Linux (NixOS), Codex app-server provider

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