Skip to content

fix(codex): let collector waits finish their full timeout - #130939

Merged
steipete merged 2 commits into
mainfrom
codex/land-qa-codex-20260827
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/land-qa-codex-20260827

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130938

Related: #111605 (the merged swarm-wait budget change).

What Problem This Solves

Fixes an issue where users waiting for collector subagents through the Codex harness receive a tool RPC timeout when requesting the supported 600-second wait. Instead of receiving the normal result listing unfinished children, the wait is aborted at its own deadline.

Why This Change Was Made

The timeout resolver already gives agents_wait a 630-second outer budget, including completion grace, but the executor reapplied the generic 600-second cap. This change removes that duplicate decision and uses the resolver's prepared budget in both normal Codex attempts and side questions.

Generic tools retain their existing 600-second maximum. Cancellation, result projection, and timer cleanup remain unchanged. There are no configuration, protocol, dependency, persistence, or plugin SDK changes. Production LOC: +3/-3 (net zero); tests: +133/-127 (net +6).

User Impact

Codex collector waits can use the documented full 600-second budget and return the structured pending-child result. Other tools keep their existing timeout policies. This restores the documented swarm wait behavior without introducing a new setting or extending the collector's own wait limit.

Evidence

Before the fix, the regression cases returning a collector result at 600,000 ms and 605,000 ms both failed: the executor returned success: false with OpenClaw dynamic tool call timed out after 600000ms while running tool agents_wait. The existing sessions_send setup-delay case passed. After the fix, all cases pass; additional tests enforce the generic 600-second cap, the collector's 630-second outer cap, and timer cleanup.

CI on the first PR head exposed the repository max-lines limit (1,031 counted lines, maximum 1,000). Consolidating six existing timeout-argument cases into a typed table preserves every case name, input, and expected result, reduces the file to 997 counted lines, and passes the same repository lint configuration. The cleanup changes tests only; no suppression or weaker assertion was added.

After that test-only cleanup, all 288 tests passed across six files in 29.32 seconds. Scoped formatting and git diff --check passed. A fresh isolated Codex autoreview considered the cleanup together with the complete final PR patch and found no issues at its P0-only threshold; it confirmed all six cases preserve their relevant inputs and assertions. The full typed-lint wrapper was also attempted, but failed before linting while preparing plugin SDK declarations because the existing shared dependency versions lack markdown-it StateInline and pi-tui TuiMainScreen exports. Dependencies were not installed or reconciled in the worktree. Exact-head hosted CI remains required.

OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE=0 \
node scripts/run-vitest.mjs \
  extensions/codex/src/app-server/dynamic-tool-execution.test.ts \
  extensions/codex/src/app-server/dynamic-tool-execution.owner-timeout.test.ts \
  extensions/codex/src/app-server/dynamic-tools.test.ts \
  extensions/codex/src/app-server/run-attempt.dynamic-tools.test.ts \
  extensions/codex/src/app-server/side-question.test.ts \
  src/agents/tools/agents-wait-tool.test.ts \
  --configLoader runner --no-cache

A separate real-clock runtime proof completed at 600,043 ms, between 2026-08-27T08:06:01.043Z and 2026-08-27T08:16:01.088Z. It registered a queued collector and required task row through canonical APIs in disposable SQLite state, then ran the actual Codex dynamic bridge, resolver, executor, and collector. It returned {"completed":[],"pending":["<run-id>"]} successfully; the 630,000 ms watchdog did not fire, and both durable rows remained queued. No fake timers or registry mocks were used. This was runtime boundary proof, not a live model or Codex app-server session. It ran on the earlier QA candidate based on ac71743ca44a1927ddf8bcd3b32d71b60e27c0ac; the production patch is byte-identical to this patch; subsequent changes only consolidate the test cases. The timeout owner, normal caller, and collector remain unchanged in the newer baseline; side-question drift is an unrelated requestOptions() correction.

Timeout policy remains with the resolver; cancellation, ordering, and cleanup are unchanged. No full build, current-head typecheck, or green hosted CI result is claimed here.

Evidence surface Source and conclusion
Timeout policy owner extensions/codex/src/app-server/dynamic-tool-execution.ts:503: resolves generic caps and collector completion grace before dispatch.
Removed duplicate policy extensions/codex/src/app-server/dynamic-tool-execution.ts:258: executor now uses the resolved budget without reclamping it.
Normal request entry extensions/codex/src/app-server/run-attempt-server-requests.ts:209,238: resolves the budget, then invokes the executor.
Sibling entry extensions/codex/src/app-server/side-question.ts:602,615: uses the same resolver and executor.
Collector callee src/agents/tools/agents-wait-tool.ts:211,286: returns current pending/completed state at its own bounded deadline.
Transport envelope extensions/codex/src/app-server/client.ts:42,895: separate 660-second request timeout remains above the 630-second collector budget.
Existing and added coverage dynamic-tool-execution.test.ts, dynamic-tool-execution.owner-timeout.test.ts, dynamic-tools.test.ts, run-attempt.dynamic-tools.test.ts, side-question.test.ts, and agents-wait-tool.test.ts.
Current upstream Codex contract Personally inspected openai/codex at 694edc23b22b4696400dc47663ecacd437623870: codex-rs/core/src/tools/handlers/dynamic.rs:137,216,227 waits for and projects the host response; codex-rs/app-server/src/dynamic_tools.rs:18,38 forwards it. No upstream requirement imposes this duplicate cap.

The best fix is to preserve the single timeout-policy owner. Raising the generic executor cap would duplicate policy again and potentially widen unrelated tool limits; adding a tool-name exception in the executor would repeat the resolver's responsibility. Neither is needed.

Provenance: the older executor clamp traces to a4c2e7f5cf1b42cc27e1d0f1573fe75c9d591875 (Peter Steinberger, 2026-05-27). The conflicting collector grace was introduced in #111605, “improve(swarm): close out wait, phase, and worker follow-ups,” merged as 7d4dccf959789331bc12cad908376ba12a3955ed on 2026-07-20. Live GitHub metadata identifies @steipete as both that PR's author and merger. The bug is the incomplete interaction between these two policies, not the collector implementation.

AI-assisted. Bounded Gitcrawl and live GitHub searches found no matching open duplicate at verification time. The open neighboring PRs #120077 (collector structured-output exposure) and #119056 (restart replay fencing) address different invariants and do not touch this timeout owner.

@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete

Copy link
Copy Markdown
Contributor Author

Head 880f1e51a258c271a87347df01784b8b6ccdc0c6 passed CI run 33078839611, including the required gate. The initial CI failure was the test file's line limit; six equivalent argument cases are now table-driven with the same names, inputs, and assertions. All 288 focused tests still pass, the lint rule passes without suppression, and fresh independent autoreview found no P0 findings.

The production owner remains byte-identical to the earlier actual 600-second collector/SQLite proof: it returned structured pending state after 600043 ms, before the existing 630000 ms watchdog. That is runtime-boundary proof, not a live Codex model/app-server E2E session. The repair removes the executor's duplicate timeout decision; generic budgets remain owned by the resolver. Production LOC is neutral; tests net +6.

Direct upstream inspection at 694edc23b22b4696400dc47663ecacd437623870 covered the core dynamic-tool handler and app-server response forwarding; neither requires the removed duplicate cap. Normal turns and side questions use the same resolver contract.

The latest ClawSweeper entry is a review-start acknowledgement with no published findings or rank-up moves. Native review artifacts are refreshed for the new head; proceeding through required preparation and merge checks.

@steipete
steipete merged commit 7e7c5d4 into main Aug 27, 2026
111 of 113 checks passed
@steipete
steipete deleted the codex/land-qa-codex-20260827 branch August 27, 2026 14:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…30939)

* fix(codex): let collector waits finish their full timeout

* test(codex): consolidate timeout argument cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex collector waits time out before returning pending tasks

1 participant