Skip to content

fix: turn-timeout gaps — interrupt, early deadline, options threading (closes #27)#28

Merged
axisrow merged 1 commit into
mainfrom
fix/turn-timeout-gaps-27
Jul 20, 2026
Merged

fix: turn-timeout gaps — interrupt, early deadline, options threading (closes #27)#28
axisrow merged 1 commit into
mainfrom
fix/turn-timeout-gaps-27

Conversation

@axisrow

@axisrow axisrow commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Closes #27. Three gaps from Codex cycle-review of PR #26.

  1. Timed-out turn not interrupted — deadline rejected await but turn/interrupt never sent. Broker kept executing write-capable turn after failure. Fix: catch deadline, best-effort interruptAppServerTurn, re-throw.
  2. Deadline armed after turn/start — stalled turn/start was unbounded. Fix: arm deadline BEFORE startRequest, race entire lifecycle.
  3. --turn-timeout-ms ignored for background — replaced env side-channel with options threading through buildTaskRequest → worker → executeTaskRun → captureTurn. Deleted applyForegroundTurnBudget.

166 tests, 162 pass / 4 pre-existing.

…st, thread through options (closes #27)

Three gaps from Codex cycle-review of PR #26:

1. Timed-out turn not interrupted: deadline rejected the await but
   turn/interrupt was never sent. The broker kept executing a write-capable
   turn after it was reported failed. Fix: catch deadline rejection,
   best-effort interruptAppServerTurn(cwd, {threadId, turnId}), re-throw.

2. Deadline armed after turn/start response: a stalled turn/start (app-server
   alive but not responding) was unbounded. Fix: arm the deadline BEFORE
   startRequest, race the entire lifecycle (startRequest + completion) against
   it. If the deadline fires during startRequest, there's no turnId to
   interrupt, but the process no longer hangs.

3. --turn-timeout-ms ignored for background: applyForegroundTurnBudget was
   foreground-only (env side-channel gated by if(!options.background)).
   Replaced with options threading: resolveTurnTimeoutMsFromOptions resolves
   the value from the flag/env/default (foreground=110s, background=600s),
   passes it through buildTaskRequest → handleTaskWorker → executeTaskRun →
   runAppServerTurn → captureTurn → resolveTurnTimeoutMs. Deleted
   applyForegroundTurnBudget (env side-channel gone). Env fallback
   (CODEX_TURN_TIMEOUT_MS) remains for operator-configured overrides.

Also threads cwd into captureTurn options (needed by the interrupt path).

Verified: 166 tests, 162 pass / 4 pre-existing (unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@axisrow
axisrow force-pushed the fix/turn-timeout-gaps-27 branch from b6b6b9d to bec139c Compare July 20, 2026 13:21
@axisrow
axisrow merged commit e42a23b into main Jul 20, 2026
@axisrow
axisrow deleted the fix/turn-timeout-gaps-27 branch July 20, 2026 13:29
axisrow added a commit that referenced this pull request Jul 21, 2026
Ships accumulated fixes since fork.4:
- #29 broker-busy hang (PR #30): bound broker handshake
- #31 spawned-app-server handshake (PR #32): bound request() primitive
- openai#508 config-driven sandbox + --read-only (PR #33) + resume-sandbox fail-closed
- #34 model/effort in /codex:rescue launch line (PR #35)
- #28 turn-timeout gaps (already in fork.4 base)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

fix: turn-timeout gaps — no interrupt on deadline, stalled turn/start uncovered, background ignores --turn-timeout-ms

1 participant