Skip to content

fix(rescue): pass timeout: 600000 on the inner task Bash call#325

Open
ultsaza wants to merge 1 commit into
openai:mainfrom
ultsaza:fix/rescue-task-bash-timeout-122
Open

fix(rescue): pass timeout: 600000 on the inner task Bash call#325
ultsaza wants to merge 1 commit into
openai:mainfrom
ultsaza:fix/rescue-task-bash-timeout-122

Conversation

@ultsaza
Copy link
Copy Markdown

@ultsaza ultsaza commented May 15, 2026

Problem

The /codex:rescue command dispatches to the codex:codex-rescue subagent, which makes one Bash call to codex-companion.mjs task. Neither the agent nor the codex-cli-runtime skill tells the model to pass a timeout, so the call inherits Claude Code's default Bash timeout of 120s. Codex rescues against non-trivial diffs routinely take several minutes; they get SIGTERM'd mid-turn at the 120s cap, leaving the companion job dangling in status: running.
The 120s default and 600s ceiling are documented in Claude Code's Bash tool reference under "Timeout: two minutes by default. Claude can request up to 10 minutes per command with the timeout parameter." Both are overridable via BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MS env vars, but passing timeout: 600000 explicitly works regardless of the user's BASH_DEFAULT_TIMEOUT_MS.

Reported in #122.

Fix

Add one bullet in each of two places, requiring timeout: 600000 (the Bash tool's 10-minute maximum) on the inner task invocation:

  • plugins/codex/agents/codex-rescue.md (Forwarding rules)
  • plugins/codex/skills/codex-cli-runtime/SKILL.md (Command selection)

Small rescues are unaffected; large-diff ones now have room to finish.

Why not the same approach as PR #239

PR #239 fixes the same 120s-cap symptom for /codex:review and /codex:adversarial-review by embedding a Bash({timeout: 600000}) block directly in those command templates. /codex:rescue cannot be fixed that way because its Bash call is constructed dynamically by the subagent, not declared in the command template — so the instruction has to live in the agent and the runtime skill that build the call.

Relationship to other open PRs

Test plan

  • node --test tests/commands.test.mjs → 8/8 pass. The new contract assertions hold (Pass \timeout: 600000`...` matches in both the agent and the runtime skill).
  • npm test (full suite): 82/86 pass. The same 4 failures are present on a pristine origin/main checkout — verified by temporarily replacing only the three files this PR modifies with their origin/main versions (git checkout origin/main -- <files>) and re-running npm test in the same environment. Identical failure set. The four are already documented as pre-existing in PR fix(runtime): add wall-clock timeouts to JSON-RPC request and captureTurn #302 and PR fix(runtime): prevent tracked jobs hanging forever on broker disconnect #184 bodies:
    • status shows phases, hints, and the latest finished job
    • status preserves adversarial review kind labels
    • result returns the stored output for the latest finished job by default
    • resolveStateDir uses a temp-backed per-workspace directory
  • Manual: a /codex:rescue invocation over a ~30-file diff that previously died at the 120s cap completes end-to-end. (Not run from the session that prepared this PR.)

Closes #122

The codex:codex-rescue subagent constructs its single `Bash` call to
`codex-companion.mjs task` dynamically from the forwarding contract. The
agent and the codex-cli-runtime skill never told the model to set a
`timeout`, so the call inherited the Bash tool's default 120s cap and
got SIGTERM'd mid-turn on any non-trivial rescue. The companion job was
then left dangling in status: running.

PR openai#239 fixed the same 120s-cap symptom for /codex:review and
/codex:adversarial-review by embedding a Bash({timeout: 600000}) block
in those command templates. /codex:rescue cannot be fixed that way
because its Bash call is constructed by the subagent, not declared in
the command template -- so the instruction has to live in the agent
and the runtime skill.

Add one bullet in each of:
- plugins/codex/agents/codex-rescue.md (Forwarding rules)
- plugins/codex/skills/codex-cli-runtime/SKILL.md (Command selection)

requiring `timeout: 600000` on the inner Bash call. 600000ms is the
10-minute maximum Claude Code's Bash tool accepts and matches the
value PR openai#239 chose for /codex:review.

Orthogonal to PR openai#214, which fixes the run_in_background problem from
issue openai#198 in the same two files. The patches touch different lines
and merge cleanly in either order.

Closes openai#122
@ultsaza ultsaza marked this pull request as ready for review May 15, 2026 19:05
@ultsaza ultsaza requested a review from a team May 15, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant