t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Codex threads read as done while the agent waits on a background command

Open niieani opened this issue 4 days ago • 1 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Start a Codex thread and ask it to run the test suite in the background and wait for the result (a long exec_command that keeps running after the turn ends).
  2. Let the turn end while the command is still running.
  3. Look at the sidebar, and at the thread shell's pendingBackgroundTasks.

Expected behavior

The thread stays in Working until the command finishes and Codex is woken with its result, as Claude, Cursor and OpenCode threads do when the agent marks the job with t3_background_wait (#24610).

Actual behavior

The thread reads as done: it leaves Working, completion alerts fire and auto-settle treats it as finished, then Codex is woken with the result a few minutes later. Calling t3_background_wait from a Codex thread returns "unsupported". Codex reports background terminals only as command_execution turn items, and pendingTaskFromTurnItem maps those to kind: "command" with no awaited, so backgroundWorkHoldsCompletion never holds for them. Clients reading pendingBackgroundTasks see the same thing.

completionWake: "always" can't be used instead: Codex sets it on every root background command, dev servers included, so treating it as a wait would bring back the stuck-in-Working problem #24610 fixed.

Impact

Minor bug or occasional failure

Version or commit

main @ 0b42e2e2fe

Environment

macOS, Codex app-server provider

niieani avatar Nov 27 '26 06:11 niieani

Seeing this on most long waits in Codex threads on 0.1.13, not occasionally. A Codex thread ran gh pr merge behind a local merge queue for 17+ minutes; the thread had a kind: "command" entry in pendingBackgroundTasks but showed as done in the sidebar the whole time. The only Codex-side workaround I found is watch_pull_request with until: "merged" when the wait happens to be a PR, since that task is awaited: true. For tests or builds there is none short of keeping the turn open.

ivogundlach avatar Nov 30 '26 13:11 ivogundlach