Repository navigation
fix(codex): honor timeoutSeconds for dynamic tool calls - #98880
harjothkhara wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 11:40 PM ET / 03:40 UTC. Summary PR surface: Source +9, Tests +57. Total +66 across 4 files. Reproducibility: yes. at source level: current main reads only Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one consolidated side-thread-aware fix after real behavior proof, preserving Do we have a high-confidence way to reproduce the issue? Yes at source level: current main reads only Is this the best way to solve the issue? Yes: the PR fixes the existing timeout readers at the owning Codex app-server boundary and is more complete than the sibling primary-reader-only PR. The best merge path still needs real behavior proof and branch consolidation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6a96bbc7ad77. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +9, Tests +57. Total +66 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
4806bd5 to
6993612
Compare
|
The PR was force-pushed and the description rewritten since the last ClawSweeper review, so the The Evidence section now has real captured before/after output from a harness that drives the real timeout-resolution + watchdog code with the tool bridge mocked as a Could this get a re-review so the proof label reflects the current revision? Happy to adjust if anything's still missing. |
|
Thanks @harjothkhara for working on this. The canonical repair has landed via #100722 as It covers the same |
Closes #98864
What Problem This Solves
Codex dynamic tool calls such as
sessions_sendcan passtimeoutSecondswithouttimeoutMs. The app-server watchdog only readtimeoutMs, so a call with a seconds-form budget fell back to the default 90-second dynamic-tool guard and long-running bounded helpers were killed early.Why This Change Was Made
The dynamic-tool timeout readers now fall back to
timeoutSecondswhentimeoutMsis absent, with two deliberate properties beyond a verbatim mapping:finiteSecondsToTimerSafeMilliseconds({ floorSeconds: true })fromopenclaw/plugin-sdk/number-runtime— the same helpersessions_senduses for the same field (src/agents/tools/sessions-send-tool.ts) — so the watchdog and the tool agree on what counts as a usable budget. A naive floor-then-multiply reading maps a fractional value like0.5to0, which survives the??fallback chain and gets clamped up to a 1 ms watchdog (instant kill of the call). The shared helper rejects it and the reader falls back to the existing default.DynamicToolCallParams.argumentsis rawJsonValuein the Codex app-server protocol (codex-rs/app-server-protocol/src/protocol/v2/item.rs,DynamicToolCallParams), so unvalidated values do reach this reader.timeoutSecondsis the tool's inner wait budget:sessions_senddoes gateway pre-work (session resolve, baseline snapshot,startAgentRun) before waiting that long, then returns a structured{status: "timeout", runId, sentBeforeError}result. A watchdog armed with exactly the same value deterministically fires first and replaces that structured result with a generic hard-timeout error, losing therunId. The watchdog is now the seconds budget plusCODEX_DYNAMIC_TOOL_SECONDS_GRACE_MS(30 s) via the sharedaddTimerTimeoutGraceMs, so the tool's own timer wins the race.timeoutMskeeps exact-override precedence and the existing 600 s hard cap is unchanged.The side-thread path previously duplicated the whole timeout-reader stack; the byte-identical
readSide*leaf readers are deleted andside-question.tsnow imports the shared readers fromdynamic-tool-execution.ts, so the main-thread and side-thread watchdogs cannot silently diverge (net-negative production LOC).AI-assisted: yes (initial implementation by Codex; multi-agent review and this revision by Claude). No agent transcript is included because sanitized transcript insertion was not approved in this automated run.
User Impact
Seconds-form dynamic-tool budgets are honored instead of being capped by the default 90-second guard. Unlike a verbatim mapping, a
sessions_sendwhose target run outlasts its budget still returns its structured timeout result (withrunIdand delivery status) instead of a generic watchdog error, and a malformed fractional budget can no longer produce an instant ~1 ms kill.Evidence
Proof harness driving the real
dynamic-tool-execution.tscode (resolveDynamicToolCallTimeoutMs+handleDynamicToolCallWithTimeout) with the tool bridge mocked as asessions_send-shaped waiter (pre-work, inner budget wait, structured timeout result). Harness kept out of the repo per contribution guidelines.On
origin/main(6e79ca3) — the reported bug,timeoutSecondsignored:On the previous head of this branch (4806bd5db5) — why the verbatim mapping was not enough:
On this branch — fixed:
node scripts/run-vitest.mjs extensions/codex/src/app-server/dynamic-tool-execution.test.ts extensions/codex/src/app-server/side-question.test.ts— 2 files, 55 tests passed, including a new fractional-seconds regression casegit diff --checkclean;oxfmt --checkclean; oxlint clean on the four changed files.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main— clean ("patch is correct", no actionable findings); an earlier autoreview run on the previous head independently flagged the zero-grace race fixed hereWhat was not tested: live end-to-end gateway + real Codex model traffic. Behavior above the pre-existing 600 s watchdog cap is unchanged (a larger budget is still capped; that cap predates this PR and applies equally to
timeoutMs).