Skip to content

fix #98864: dynamic tool hard timeout should honor timeoutSeconds when timeoutMs is absent - #100848

Closed
jincheng-xydt wants to merge 1 commit into
openclaw:mainfrom
jincheng-xydt:fix/dynamic-tool-timeout-seconds-98864
Closed

jincheng-xydt wants to merge 1 commit into
openclaw:mainfrom
jincheng-xydt:fix/dynamic-tool-timeout-seconds-98864

Conversation

@jincheng-xydt

Copy link
Copy Markdown
Contributor

Summary

  • Problem: Dynamic tool calls can carry a timeoutSeconds field while omitting timeoutMs. The hard-call timeout reader (readDynamicToolCallTimeoutMs) only checked timeoutMs, so a tool configured with timeoutSeconds fell through to the default hard-call guard (90s). This affects long-running tools such as session send helpers.
  • Solution: Update readDynamicToolCallTimeoutMs to treat timeoutSeconds as the seconds-form fallback when timeoutMs is absent, reusing the existing readTimeoutSecondsAsMs helper for consistency.
  • What changed: dynamic-tool-execution.ts — 3-line change in readDynamicToolCallTimeoutMs. dynamic-tool-execution.test.ts — 7 new tests covering timeoutSeconds fallback, precedence, invalid values, and max-capping.
  • What did NOT change: No schema, config, API, or provider changes. readTimeoutSecondsAsMs and readPositiveFiniteTimeoutMs helpers unchanged.

Maintainer checklist

  • Fix classification: Root-cause bug fix in Codex dynamic tool timeout resolution
  • Maintainer-ready confidence: High — all 20 tests pass on upstream/main base, including 7 new timeoutSeconds fallback tests

Real behavior proof

Behavior or issue addressed:
Dynamic tool calls with timeoutSeconds but no timeoutMs silently fall through to the default 90s hard-call guard instead of honoring the caller-specified timeout.

Real environment tested:

  • Platform: Linux x86_64
  • Node.js: v22.22.0
  • Runtime: Vitest v4.1.8
  • Branch: fix/dynamic-tool-timeout-seconds-98864 (bea0183) — based on upstream/main

Exact steps or command run after the patch:

node ./node_modules/vitest/vitest.mjs run extensions/codex/src/app-server/dynamic-tool-execution.test.ts --reporter=verbose

After-fix evidence:
All 20 tests pass including 7 new timeoutSeconds fallback tests:

  • uses timeoutSeconds when timeoutMs is absent (30 → 30,000ms) ✓
  • prefers timeoutMs when both timeoutMs and timeoutSeconds are provided ✓
  • ignores non-number timeoutSeconds ("30" → default) ✓
  • ignores non-positive timeoutSeconds (0 → default) ✓
  • ignores negative timeoutSeconds (-5 → default) ✓
  • caps timeoutSeconds exceeding the maximum (9999 → 600,000ms) ✓
  • preserves existing timeoutMs behavior unchanged ✓

Acceptance criteria satisfied:

  • A dynamic tool call with timeoutMs keeps existing behavior ✓
  • A dynamic tool call with only timeoutSeconds uses that value as the hard timeout ✓
  • Invalid or non-positive timeoutSeconds values are ignored ✓
  • Timeout values exceeding CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS are capped ✓

What was not tested:

  • End-to-end with live model calling sessions_send with timeoutSeconds
  • Gateway restart + dynamic tool call integration flow

🤖 Generated with Claude Code

…tool hard timeout (openclaw#98864)

Dynamic tool calls can carry a timeoutSeconds field while omitting
timeoutMs. The hard-call timeout reader only checked timeoutMs, so
a tool configured with timeoutSeconds fell through to the default
hard-call guard.

Update readDynamicToolCallTimeoutMs to treat timeoutSeconds as the
seconds-form fallback when timeoutMs is absent, reusing the existing
readTimeoutSecondsAsMs helper for consistency with media image config.

Acceptance:
- timeoutMs keeps existing behavior (takes precedence)
- timeoutSeconds used as hard timeout when timeoutMs absent
- Invalid/non-positive timeoutSeconds ignored (falls to default)
- Values exceeding CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS are capped

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

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 7:47 AM ET / 11:47 UTC.

Summary
The branch changes the Codex primary dynamic-tool timeout reader and focused tests so timeoutSeconds is used when timeoutMs is absent.

PR surface: Source +3, Tests +115. Total +118 across 2 files.

Reproducibility: yes. at source level: current main reads only timeoutMs in the primary and side-question Codex dynamic-tool timeout readers, while sessions_send exposes timeoutSeconds and upstream Codex forwards raw dynamic-tool arguments. I did not run a live current-main Codex timeout turn in this read-only review.

Review metrics: 1 noteworthy metric.

  • Timeout readers covered: 1 changed, 1 unchanged sibling. The primary and side-question Codex dynamic-tool paths share the same timeout argument invariant, but this PR updates only the primary reader.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98864
Summary: This PR is one candidate fix for the canonical Codex dynamic-tool timeoutSeconds bug, but the cluster still has multiple open overlapping PRs with different completeness and timeout semantics.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • Share validated timeoutSeconds handling across primary and side-question readers, including fractional rejection and timeoutMs precedence tests.
  • [P2] Add grace/headroom proof for a sessions_send-style inner timeout result so the structured result wins before the outer watchdog.
  • [P1] Add redacted runtime evidence from a real Codex dynamic-tool call or logs showing timeoutSeconds behavior after the fix.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body reports a focused Vitest run and pass list, but it does not include a real Codex dynamic-tool call, runtime log, terminal transcript, recording, or linked artifact showing after-fix timeoutSeconds behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P2] Merging the exact seconds-to-watchdog mapping can change sessions_send calls with short timeoutSeconds from a structured timeout result with run context into a generic Codex hard-timeout response.
  • [P1] The side-question dynamic-tool path still ignores timeoutSeconds, so the linked issue could be closed while a sibling runtime path remains broken.
  • [P1] The PR proof is mock/test-only; the contributor has not shown a real Codex dynamic-tool call, runtime log, or terminal transcript exercising the after-fix behavior.
  • [P1] Several open sibling PRs target the same canonical issue, so maintainers need one complete landing path before overlapping fixes merge.

Maintainer options:

  1. Consolidate a complete timeout fix (recommended)
    Update this branch or a chosen sibling so main and side-question readers share validated timeoutSeconds conversion, preserve timeoutMs precedence, and leave grace for tool-owned timeout results before merge.
  2. Accept exact watchdog semantics
    Maintainers may intentionally accept a generic hard-timeout response for timeoutSeconds, but that should be stated explicitly and backed by runtime proof.
  3. Pause for a sibling landing path
    If another open candidate is preferred, keep this PR paused or close it only after the chosen PR is viable and proof-positive.

Next step before merge

  • [P1] Manual follow-up is needed because this external PR has blocking code findings plus contributor-supplied real behavior proof still missing.

Security
Cleared: The diff only changes Codex timeout parsing logic and focused tests; no dependency, workflow, package, secret, or code-download security concern was found.

Review findings

  • [P1] Leave headroom for tool-owned timeoutSeconds waits — extensions/codex/src/app-server/dynamic-tool-execution.ts:447-450
  • [P2] Update the side-question timeout reader too — extensions/codex/src/app-server/dynamic-tool-execution.ts:447-450
  • [P2] Reject fractional timeoutSeconds before arming the watchdog — extensions/codex/src/app-server/dynamic-tool-execution.ts:449-450
Review details

Best possible solution:

Land one consolidated Codex app-server fix that shares validated timeoutSeconds handling across the primary and side-question readers, keeps timeoutMs exact, adds outer-watchdog headroom for tool-owned seconds budgets, rejects fractional seconds consistently, and includes redacted runtime proof.

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

Yes at source level: current main reads only timeoutMs in the primary and side-question Codex dynamic-tool timeout readers, while sessions_send exposes timeoutSeconds and upstream Codex forwards raw dynamic-tool arguments. I did not run a live current-main Codex timeout turn in this read-only review.

Is this the best way to solve the issue?

No. The patch addresses the primary reader but misses the side-question sibling path and should not map tool-owned timeoutSeconds budgets to an exact outer watchdog without validation and headroom.

Full review comments:

  • [P1] Leave headroom for tool-owned timeoutSeconds waits — extensions/codex/src/app-server/dynamic-tool-execution.ts:447-450
    This maps timeoutSeconds straight into the outer Codex watchdog. sessions_send uses the same field as its inner wait budget after session resolution, snapshots, and run startup, so the outer watchdog can win first and replace the structured {status:"timeout", runId, ...} tool result with a generic hard-timeout response. Add a small grace window/shared helper for seconds-form budgets while keeping timeoutMs exact.
    Confidence: 0.91
  • [P2] Update the side-question timeout reader too — extensions/codex/src/app-server/dynamic-tool-execution.ts:447-450
    This PR fixes only the primary dynamic-tool timeout reader. Side questions also handle item/tool/call through resolveSideDynamicToolCallTimeoutMs, but that sibling reader still reads only value.timeoutMs, so side-thread calls with only timeoutSeconds continue to fall back to the default watchdog. Apply the same validated fallback and add side-question coverage before closing the linked bug.
    Confidence: 0.94
  • [P2] Reject fractional timeoutSeconds before arming the watchdog — extensions/codex/src/app-server/dynamic-tool-execution.ts:449-450
    readTimeoutSecondsAsMs uses the positive finite reader, so a raw timeoutSeconds: 0.5 becomes 0 milliseconds before the final clamp turns it into a near-immediate watchdog. sessions_send declares this field as an integer and rejects fractional input, so the outer reader should share that validated contract instead of creating a 1 ms timeout from invalid model JSON.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR targets a bounded Codex dynamic-tool timeout bug with real but limited impact on long-running session-helper calls.
  • add merge-risk: 🚨 compatibility: The exact timeoutSeconds watchdog can change existing sessions_send timeout result shape for callers that currently receive structured tool-owned timeout metadata.
  • add merge-risk: 🚨 session-state: A generic outer watchdog timeout can drop run, delivery, and session context that sessions_send returns on its own timeout path.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a focused Vitest run and pass list, but it does not include a real Codex dynamic-tool call, runtime log, terminal transcript, recording, or linked artifact showing after-fix timeoutSeconds behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The PR targets a bounded Codex dynamic-tool timeout bug with real but limited impact on long-running session-helper calls.
  • merge-risk: 🚨 compatibility: The exact timeoutSeconds watchdog can change existing sessions_send timeout result shape for callers that currently receive structured tool-owned timeout metadata.
  • merge-risk: 🚨 session-state: A generic outer watchdog timeout can drop run, delivery, and session context that sessions_send returns on its own timeout path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a focused Vitest run and pass list, but it does not include a real Codex dynamic-tool call, runtime log, terminal transcript, recording, or linked artifact showing after-fix timeoutSeconds behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +3, Tests +115. Total +118 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 115 0 +115
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 119 1 +118

What I checked:

Likely related people:

  • steipete: Recent path history includes multiple current-main commits touching dynamic-tool execution and side-question app-server behavior, including terminal outcome ordering and Codex app-server documentation. (role: recent Codex app-server contributor; confidence: high; commits: f53346944db0, a09f6b1b2787, 7139f473332f; files: extensions/codex/src/app-server/dynamic-tool-execution.ts, extensions/codex/src/app-server/side-question.ts)
  • harjothkhara: Recent merged work changed timeout-sensitive sessions_send behavior, and this path is the concrete tool surface that exposes the timeoutSeconds argument involved in the bug. (role: recent sessions_send contributor; confidence: medium; commits: c49714f7b6d2; files: src/agents/tools/sessions-send-tool.ts)
  • vincentkoc: Recent history includes side-question and sessions_send adjacent runtime work in the same Codex/session area. (role: adjacent Codex and session contributor; confidence: medium; commits: 5c3469549159, 3659ff8bbf71; files: extensions/codex/src/app-server/side-question.ts, src/agents/tools/sessions-send-tool.ts)
  • udaymanish6: Earlier current-main path history includes work titled fix(codex): raise dynamic tool timeout on the Codex app-server timeout surface. (role: adjacent Codex timeout contributor; confidence: low; commits: 0f18d52f16e3; files: extensions/codex/src/app-server/side-question.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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. 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. labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @jincheng-xydt 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants