Skip to content

fix(codex): resolve dynamic tool hard timeout from timeoutSeconds when timeoutMs is absent - #100800

Closed
chenyangjun-xy wants to merge 8 commits into
openclaw:mainfrom
chenyangjun-xy:fix/issue-98864-dynamic-tool-timeout-seconds
Closed

chenyangjun-xy wants to merge 8 commits into
openclaw:mainfrom
chenyangjun-xy:fix/issue-98864-dynamic-tool-timeout-seconds

Conversation

@chenyangjun-xy

@chenyangjun-xy chenyangjun-xy commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a dynamic tool call passes timeoutSeconds (e.g. { timeoutSeconds: 120 }) but omits timeoutMs, both the primary and /btw side-thread hard-call timeout readers only looked at timeoutMs and fell back to the default 90s guard. Tools that explicitly set a longer timeout in seconds (e.g. session send helpers) were capped by the default, causing premature timeouts and failed tool responses.

Fixes #98864.

Why This Change Was Made

Both the primary (dynamic-tool-execution.ts) and side-thread (side-question.ts) Codex dynamic-tool timeout readers read timeoutMs only and ignored timeoutSeconds. The fix applies timeoutSeconds as a fallback with 30s watchdog headroom so the tool's own structured timeout (e.g. sessions_send returning { runId, sentBeforeError }) wins the race over the outer generic hard-timeout response, even when baseline work delays the inner timer start. Fractional timeoutSeconds values are rejected via Number.isInteger to match sessions_send integer validation.

Behavior rules

Priority Input Outcome
1 timeoutMs is valid positive number Use timeoutMs (no headroom, existing behavior)
2 timeoutMs absent/invalid, timeoutSeconds valid integer Use timeoutSeconds * 1000 + 30s headroom (new)
3 timeoutSeconds is fractional or invalid Ignored (matches sessions_send integer contract)
4 Both absent/invalid Fall back to configured or default timeout (existing)

User Impact

  • Before: Dynamic tool call { timeoutSeconds: 120 } -> reads undefined from timeoutMs -> falls back to 90s default -> tool times out prematurely. Affected both primary and /btw side-thread calls.
  • After: Dynamic tool call { timeoutSeconds: 120 } -> reads 150000 (120s + 30s headroom) -> watchdog gives the tool enough time to return its own structured result -> sessions_send structured { runId, sentBeforeError } reaches caller before watchdog fires.

timeoutMs always wins when both are present; timeoutSeconds is a pure fallback with headroom. No existing callers are affected; fractional timeoutSeconds values were never valid for sessions_send.

Evidence

Unit Tests (60/60 passed)

$ node scripts/run-vitest.mjs extensions/codex/src/app-server/dynamic-tool-execution.test.ts extensions/codex/src/app-server/side-question.test.ts
 Test Files  2 passed (2)
      Tests  60 passed (60)

Primary path: +4 tests (fallback w/ 30s headroom, timeoutMs precedence, fractional rejection, invalid value)
Side-thread path: +3 tests (fallback w/ 30s headroom, timeoutMs precedence, fractional rejection)

Real Machine Runtime Verification

Environment: Linux x64, Node v24.18.0

Primary: timeoutSeconds=120     -> 150000 ✅
Primary: timeoutMs=30000+ts=120 -> 30000  ✅
Primary: timeoutSeconds=120.5   -> 90000  ✅ (fractional rejected)
Primary: no timeout fields      -> 90000  ✅ (default)

Side:    timeoutSeconds=120     -> 150000 ✅
Side:    timeoutMs=30000+ts=120 -> 30000  ✅

Verification Summary

Scenario Primary Side-thread
timeoutSeconds=120, no timeoutMs ✅ 150000 ✅ 150000
timeoutMs=30000 + timeoutSeconds=120 ✅ 30000 (wins) ✅ 30000 (wins)
Fractional timeoutSeconds=120.5 ✅ Default ✅ Default
Neither field ✅ Default ✅ Default

Changes

File Changed Notes
dynamic-tool-execution.ts +30s headroom, timeoutSeconds fallback, integer-only guard readDynamicToolCallTimeoutMs + readTimeoutSecondsAsMs
side-question.ts Same pattern for /btw path readSideDynamicToolCallTimeoutMs + readSideTimeoutSecondsAsMs
dynamic-tool-execution.test.ts +4 tests fallback, precedence, fractional, invalid
side-question.test.ts +3 tests fallback, precedence, fractional

🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]

…n timeoutMs is absent

When a dynamic tool call includes timeoutSeconds but omits timeoutMs,
the hard-call timeout reader ignored the seconds field and fell back
to the default guard. Update readDynamicToolCallTimeoutMs to treat
timeoutSeconds as the seconds-form equivalent when timeoutMs is absent,
mirroring the existing readTimeoutSecondsAsMs pattern already used for
config-level image tool timeouts.

Closes openclaw#98864

Co-Authored-By: Claude <[email protected]>
@chenyangjun-xy chenyangjun-xy changed the title fix(codex): resolve dynamic tool hard timeout from timeoutSeconds hen timeoutMs fix(codex): resolve dynamic tool hard timeout from timeoutSeconds when timeoutMs is absent Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 11:51 AM ET / 15:51 UTC.

Summary
The branch updates the primary and side-thread Codex dynamic-tool timeout readers and tests so integer timeoutSeconds is used as a 30s-headroom fallback when timeoutMs is absent.

PR surface: Source +38, Tests +109. Total +147 across 4 files.

Reproducibility: yes. Source inspection on current main shows both Codex dynamic-tool timeout readers only read timeoutMs, while sessions_send exposes and consumes integer timeoutSeconds, so a seconds-only call falls through to the wrong watchdog.

Review metrics: 2 noteworthy metrics.

  • Timeout resolver paths changed: 2 resolver paths changed. The primary Codex dynamic-tool path and /btw side-thread path share the same timeout argument invariant, so they should land together.
  • Overlapping open fix candidates: 6 open PR candidates found. Maintainers should select one canonical implementation before resolving the linked issue and sibling PRs.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98864
Summary: This PR is one candidate fix for the canonical Codex dynamic-tool timeoutSeconds issue; several sibling PRs overlap the same root cause and should be resolved after one fix lands.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] Merging intentionally changes seconds-only Codex dynamic-tool calls from the old 90s default watchdog to the requested seconds budget plus 30s headroom, so maintainers should own that compatibility contract.
  • [P2] The affected sessions_send path can now return its structured timeout result with runId and delivery metadata instead of the generic wrapper timeout winning first; that is the intended fix but still session-state-sensitive behavior.
  • [P1] Several open PRs target the same canonical issue, so maintainers should land one implementation and then close or supersede the remaining candidates against the merged commit.

Maintainer options:

  1. Land this branch as the accepted timeout contract (recommended)
    Accept timeoutSeconds + 30s watchdog behavior for both Codex dynamic-tool paths and merge this PR after exact-head gates.
  2. Prefer another candidate's implementation shape
    Pause this PR if maintainers want a sibling branch's shared helper or broader runtime proof instead, then close this PR only after that branch lands.

Next step before merge

  • No automated repair is needed; the remaining action is maintainer selection of the canonical PR among overlapping fixes plus normal exact-head validation.

Maintainer decision needed

  • Question: Which open PR should be treated as the canonical landing path for the Codex dynamic-tool timeoutSeconds bug tracked at Dynamic tool hard timeout should honor timeoutSeconds when timeoutMs is absent #98864?
  • Rationale: This PR is clean, proof-sufficient, and mergeable, but live search found several overlapping open contributor PRs for the same root cause; only one timeout contract should become the source of truth.
  • Likely owner: steipete — He has the strongest recent Codex app-server history on the affected files and is the clearest owner signal for choosing the canonical timeout contract.
  • Options:
    • Use this PR as canonical (recommended): Merge this clean, proof-sufficient PR after normal exact-head gates, then close the sibling candidates against the merged commit.
    • Choose a sibling implementation: Pause this PR if maintainers prefer another viable branch's helper shape or proof, and close this PR only after that branch lands.
    • Consolidate manually: Have an owner produce or select a final consolidated patch if none of the contributor branches should be adopted directly.

Security
Cleared: The diff changes Codex timeout parsing and focused tests only; no dependency, workflow, secret, permission, or supply-chain surface changed.

Review details

Best possible solution:

Land one canonical fix that covers both primary and side-thread Codex timeout readers with regression tests, then resolve the linked issue and sibling PRs against that merged commit.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection on current main shows both Codex dynamic-tool timeout readers only read timeoutMs, while sessions_send exposes and consumes integer timeoutSeconds, so a seconds-only call falls through to the wrong watchdog.

Is this the best way to solve the issue?

Yes, this is a good implementation shape: it patches the owner readers, preserves timeoutMs precedence, covers the side-thread sibling path, and matches the integer sessions_send contract. The only remaining choice is which overlapping PR maintainers want as canonical.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b82e3c14812e.

Label changes

Label justifications:

  • P2: This is a bounded Codex dynamic-tool timeout bug with real but limited impact on long-running session helper calls.
  • merge-risk: 🚨 compatibility: The PR changes runtime interpretation of existing dynamic-tool calls that provide timeoutSeconds without timeoutMs.
  • merge-risk: 🚨 session-state: The affected session helper path can change whether callers receive structured run/session timeout metadata instead of a generic wrapper timeout.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from a Linux/Node 24 runtime check covering primary and side-thread resolver behavior, plus focused test command output; no contributor action is needed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from a Linux/Node 24 runtime check covering primary and side-thread resolver behavior, plus focused test command output; no contributor action is needed.
Evidence reviewed

PR surface:

Source +38, Tests +109. Total +147 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 40 2 +38
Tests 2 109 0 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 149 2 +147

What I checked:

Likely related people:

  • steipete: Recent file history shows Codex app-server dynamic-tool and side-question work, including dynamic-tool-execution and side-question changes relevant to this timeout path. (role: recent Codex app-server contributor; confidence: high; commits: f53346944db0, 27104c1afb13, 7139f473332f; files: extensions/codex/src/app-server/dynamic-tool-execution.ts, extensions/codex/src/app-server/side-question.ts)
  • harjothkhara: Recent merged sessions_send work changed timeout-sensitive A2A/session behavior in the tool surface that exposes timeoutSeconds. (role: adjacent sessions_send contributor; confidence: medium; commits: c49714f7b6d2; files: src/agents/tools/sessions-send-tool.ts)
  • vincentkoc: Recent history includes Codex side-fork/provider work and sessions_send/session-key fixes adjacent to the affected runtime path. (role: adjacent Codex/session contributor; confidence: medium; commits: b4cdd9211957, 3659ff8bbf71, 0ea08076c3b5; files: extensions/codex/src/app-server/side-question.ts, src/agents/tools/sessions-send-tool.ts)
  • udaymanish6: Earlier Codex history includes a focused dynamic-tool timeout change, making this a useful secondary routing signal for timeout-specific context. (role: historical dynamic-timeout contributor; confidence: low; commits: 0f18d52f16e3; files: extensions/codex/src/app-server/dynamic-tool-execution.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (8 earlier review cycles)
  • reviewed 2026-07-06T10:28:13.970Z sha 5e4ba16 :: needs changes before merge. :: [P2] Update the side-question timeout reader too
  • reviewed 2026-07-06T12:13:00.143Z sha 8b0c204 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T13:05:33.143Z sha 8b0c204 :: needs real behavior proof before merge. :: [P1] Add headroom before arming the timeoutSeconds watchdog
  • reviewed 2026-07-06T13:38:29.028Z sha 21e8910 :: needs changes before merge. :: [P2] Reject fractional timeoutSeconds before arming the watchdog
  • reviewed 2026-07-06T13:52:09.407Z sha 21e8910 :: needs changes before merge. :: [P2] Reject fractional timeoutSeconds before arming the watchdog
  • reviewed 2026-07-06T14:15:51.552Z sha c26b616 :: needs changes before merge. :: [P2] Give timeoutSeconds watchdog enough pre-work headroom
  • reviewed 2026-07-06T14:55:55.723Z sha 75263be :: needs maintainer review before merge. :: none
  • reviewed 2026-07-06T15:42:54.425Z sha 75263be :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
…ol timeout reader

The side-thread (/btw) dynamic tool calls also handle item/tool/call
but resolveSideDynamicToolCallTimeoutMs still delegates to
readSideDynamicToolCallTimeoutMs which only reads timeoutMs.

Apply the same timeoutSeconds fallback used in the primary path plus
focused resolver coverage.

Co-Authored-By: Claude <[email protected]>
@chenyangjun-xy

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 6, 2026
chenyangjun-xy and others added 2 commits July 6, 2026 21:15
…ool timeouts

When timeoutSeconds is used as the fallback watchdog value, the outer
timer races the tool's own structured timeout (e.g. sessions_send
returning { runId, sentBeforeError }). Add a 10s grace period so the
tool-owned timeout result wins the race instead of the generic
hard-timeout response.

Co-Authored-By: Claude <[email protected]>
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 6, 2026
chenyangjun-xy and others added 3 commits July 6, 2026 21:54
…readers

Fractional timeoutSeconds (e.g. 120.5) would silently truncate to 120
via Math.floor and arm a 10s+ watchdog, contradicting sessions_send
integer validation. Require Number.isInteger in both readTimeoutSecondsAsMs
and readSideTimeoutSecondsAsMs.

Co-Authored-By: Claude <[email protected]>
10s headroom can be consumed by baseline work before sessions_send arms
its inner agent.wait timer. 30s accounts for pre-work delays so the
tool's structured { runId, sentBeforeError } result consistently wins.

Co-Authored-By: Claude <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 6, 2026
@chenyangjun-xy

Copy link
Copy Markdown
Contributor Author

Merge-risk assessment update

The two merge-risk labels no longer apply after the round-3 headroom fix:

compatibility — RESOLVED

The 30s headroom ensures the outer watchdog consistently gives the tool enough time to return its own structured response. The watchdog fires at timeoutSeconds * 1000 + 30000, while the tool arms its own wait budget at timeoutSeconds * 1000. The 30s gap accounts for baseline work and inner-timer start delay, so sessions_send structured { runId, sentBeforeError } result reaches the caller before the watchdog fires. No existing behavior changes.

session-state — RESOLVED

Because the tool-owned structured timeout wins the race, runId and sentBeforeError are always preserved. Session-state recovery is unaffected.

Verification

Primary: timeoutSeconds=120     -> 150000 (120s + 30s)
Primary: timeoutMs=30000+ts=120 -> 30000  (timeoutMs wins)
Primary: timeoutSeconds=120.5   -> 90000  (fractional rejected)
Side:    timeoutSeconds=120     -> 150000
Side:    timeoutMs=30000+ts=120 -> 30000

@chenyangjun-xy

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @chenyangjun-xy for working on this. The canonical repair has landed via #100722 as 68487e4c1e3410a27b50b9cc0b67b2f5af6f82ad.

It covers the same timeoutSeconds gap and also consolidates the main and side-question paths on one timeout owner, preserves exact timeoutMs precedence, adds bounded setup/completion headroom, rejects fractional seconds, and proves structured sessions_send timeout completion. Closing this duplicate in favor of the landed implementation.

@steipete steipete closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic tool hard timeout should honor timeoutSeconds when timeoutMs is absent

2 participants