Skip to content

fix(codex): honor timeoutSeconds for dynamic tool calls when timeoutMs is absent - #100722

Merged
steipete merged 7 commits into
openclaw:mainfrom
cxbAsDev:fix/codex-dynamic-tool-timeout-seconds
Jul 6, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
cxbAsDev:fix/codex-dynamic-tool-timeout-seconds

Conversation

@cxbAsDev

@cxbAsDev cxbAsDev commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #98864.

What Problem This Solves

Codex dynamic tool calls forward tool arguments as JSON. Tools such as sessions_send expose an integer timeoutSeconds budget, but OpenClaw's outer dynamic-tool watchdog only honored timeoutMs. Seconds-only calls therefore inherited the generic 90-second watchdog, and a short inner timeout could race the outer bridge after target-resolution/setup work instead of returning its structured timeout result.

Why This Change Was Made

  • Use the existing dynamic-tool timeout owner for both the main run and side-question path; remove the duplicate side implementation.
  • Preserve exact timeoutMs precedence when it is supplied.
  • Interpret positive integer timeoutSeconds when timeoutMs is absent, with bounded 30-second outer headroom for setup and structured completion.
  • Keep the existing hard cap and configured media timeout behavior.
  • Reject fractional model-facing seconds rather than silently shortening them.

This is the correct ownership boundary: upstream Codex forwards dynamic-tool arguments unchanged and waits for the returned tool response, while OpenClaw owns the tool schema and watchdog policy. Relevant upstream source: https://github.com/openai/codex/blob/be33f80bc65159c094ecd06bf155afa3061ce23d/codex-rs/protocol/src/dynamic_tools.rs#L45 and https://github.com/openai/codex/blob/be33f80bc65159c094ecd06bf155afa3061ce23d/codex-rs/core/src/tools/handlers/dynamic.rs#L127

User Impact

Seconds-only dynamic tool calls now get the intended bounded budget on both Codex run paths. A tool can finish its own timeout handling and return structured state instead of being preempted by the generic bridge watchdog.

Evidence

@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 12:26 PM ET / 16:26 UTC.

Summary
The PR adds timeoutSeconds fallback with integer validation and 30s outer-watchdog grace for Codex dynamic tool calls, reuses the shared timeout handler for side-question tool calls, and updates focused tests.

PR surface: Source -114, Tests +57. Total -57 across 4 files.

Reproducibility: yes. source-level reproduction is high confidence: current main reads only timeoutMs, while sessions_send exposes and consumes timeoutSeconds. I did not run a live Codex app-server timeout turn in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98864
Summary: The linked issue is the canonical report for the Codex dynamic-tool timeoutSeconds gap; this PR and two sibling PRs are candidate fixes, while the CI-flake and gateway-protocol PRs are adjacent blockers/noise rather than the same root cause.

Members:

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

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • Update the PR body with current-head real behavior proof, redacting private paths, endpoints, tokens, phone numbers, and other private details.
  • [P1] Rerun or inspect check-test-types once logs are available and fix it if the failure is from this branch.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR contains terminal proof from earlier heads, but it no longer proves the current head because the current diff changed the grace behavior and removed the proof script; please add redacted current-head terminal output, logs, or a reproducible runtime transcript. 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

  • [P1] The PR body and proof comments describe earlier proof-script output that no longer matches the current head, after maintainer commits changed the grace budget and removed the proof script from the diff.
  • check-test-types is failing on the current head; without logs, this review cannot tell whether it is a PR-introduced type issue or unrelated CI noise.

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared Codex dynamic-tool timeout resolver after the current head has fresh proof and either green check-test-types or a concrete maintainer explanation for that failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No narrow code repair is identified from source review; the remaining blocker is proof freshness plus the current failing type-check result.

Maintainer decision needed

  • Question: Should this maintainer-updated head wait for fresh current-head real behavior proof and a resolved check-test-types result before merge?
  • Rationale: The code path looks correct, but the available terminal proof predates the current head and the current CI failure was not inspectable from logs during this review.
  • Likely owner: steipete — This account authored the current-head maintainer commits that changed the proof-relevant behavior and tests.
  • Options:
    • Require current-head proof (recommended): Ask for updated terminal output, logs, or an equivalent redacted runtime transcript for the current head, then rerun or inspect check-test-types before merge.
    • Maintainer proof override: A maintainer may accept responsibility for the current-head proof gap if they have separate local or Testbox evidence not visible on the PR.
    • Pause for CI diagnosis: Hold the PR until the failing type-check logs are available and a narrow fix or rerun decision is clear.

Security
Cleared: The current diff touches Codex runtime/test code only, with no dependency, workflow, lockfile, secret, or supply-chain surface added.

Review details

Best possible solution:

Land the shared Codex dynamic-tool timeout resolver after the current head has fresh proof and either green check-test-types or a concrete maintainer explanation for that failure.

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

Yes, source-level reproduction is high confidence: current main reads only timeoutMs, while sessions_send exposes and consumes timeoutSeconds. I did not run a live Codex app-server timeout turn in this read-only review.

Is this the best way to solve the issue?

Yes for the code shape: sharing the main dynamic-tool timeout resolver and handler with the side-question path is narrower and less duplicative than maintaining two timeout implementations. Merge readiness still depends on current-head proof and the failing type-check result.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR contains terminal proof from earlier heads, but it no longer proves the current head because the current diff changed the grace behavior and removed the proof script; please add redacted current-head terminal output, logs, or a reproducible runtime transcript. 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: This fixes a real but bounded Codex dynamic-tool timeout bug affecting session-helper calls rather than a core runtime outage.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR contains terminal proof from earlier heads, but it no longer proves the current head because the current diff changed the grace behavior and removed the proof script; please add redacted current-head terminal output, logs, or a reproducible runtime transcript. 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 -114, Tests +57. Total -57 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 36 150 -114
Tests 2 109 52 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 145 202 -57

What I checked:

Likely related people:

  • steipete: Git history shows repeated Codex app-server work by Peter Steinberger, and the latest PR head includes maintainer commits by this account that reshape the timeout fix and tests. (role: recent area contributor and current-head maintainer contributor; confidence: high; commits: 1d7d34539c42, b65fa0cb3bab, 12e332fb7473; files: extensions/codex/src/app-server/dynamic-tool-execution.ts, extensions/codex/src/app-server/side-question.ts, extensions/codex/src/app-server/run-attempt.ts)
  • vincentkoc: Recent history on the Codex app-server runtime includes Vincent Koc commits, including the latest release commit carrying the current shipped behavior. (role: recent Codex app-server contributor; confidence: medium; commits: e085fa1a3ffd, f1cc8f0cfc7c, 859eb0666282; files: extensions/codex/src/app-server/run-attempt.ts, extensions/codex/src/app-server/dynamic-tool-execution.ts)
  • SnowSky1: Recent history on the sessions_send tests and tool behavior includes a SnowSky1 fix in the affected tool family. (role: adjacent sessions_send contributor; confidence: medium; commits: 03f2951e63c4; files: src/agents/tools/sessions-send-tool.ts, src/agents/openclaw-tools.sessions.test.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 (6 earlier review cycles)
  • reviewed 2026-07-06T08:16:24.057Z sha a58706060222cfc641289545325ad5919777580e :: needs real behavior proof before merge. :: [P2] Cover the side-question timeout reader too
  • reviewed 2026-07-06T09:27:24.594Z sha df854545f0ac1eef1241dc78caa712cefc4200f0 :: needs real behavior proof before merge. :: [P2] Cover the side-question timeout reader too | [P2] Reject fractional timeoutSeconds before arming the watchdog
  • reviewed 2026-07-06T10:40:07.712Z sha 1bf877a2d6b589a34fe43d01c45dbaab6e17ad35 :: needs changes before merge. :: [P1] Leave headroom for tool-owned timeouts
  • reviewed 2026-07-06T12:36:52.900Z sha c175c17be5ea2a0865471b2ed549a9e33d8b417f :: needs changes before merge. :: [P1] Leave headroom for tool-owned timeouts
  • reviewed 2026-07-06T14:40:29.652Z sha f5fab782c5b85cdc4fc32d99b5c580ac8fff1648 :: needs changes before merge. :: [P1] Keep the sessions_send timeout in front
  • reviewed 2026-07-06T15:57:26.549Z sha d30a08dec70730ddc4f66d70baf42892e05aac16 :: needs changes before merge. :: [P3] Document the new timeoutSeconds watchdog semantics

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 6, 2026
@cxbAsDev
cxbAsDev force-pushed the fix/codex-dynamic-tool-timeout-seconds branch 2 times, most recently from df85454 to 23bc37d Compare July 6, 2026 09:42
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Updated #100722 to address the latest ClawSweeper feedback:

  1. Side-question path covered: readSideDynamicToolCallTimeoutMs now falls back to timeoutSeconds when timeoutMs is absent, mirroring the main dynamic tool path.
  2. Integer validation enforced: readTimeoutSecondsAsMs and readSideTimeoutSecondsAsMs now reject fractional timeoutSeconds values instead of silently flooring them, matching the sessions_send tool schema (Type.Integer).
  3. Tests added: dynamic-tool-execution.test.ts and side-question.test.ts now cover the new behavior.
  4. Proof script extended: scripts/proof/codex-dynamic-tool-timeout-seconds.mts exercises both main and side-question paths, including fractional rejection.

Evidence:

pnpm test 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)

node_modules/.bin/tsx scripts/proof/codex-dynamic-tool-timeout-seconds.mts
# All cases passed (main + side-question, including fractional rejection).

@cxbAsDev
cxbAsDev force-pushed the fix/codex-dynamic-tool-timeout-seconds branch from 627bb84 to b5f1255 Compare July 6, 2026 10:15
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the proof script to exercise the actual runtime handlers:

  • handleDynamicToolCallWithTimeout is called with a fake tool that sleeps past the timeoutSeconds deadline, asserting a timeout failure response.
  • handleSideDynamicToolCallWithTimeout is now exposed via __testing in side-question.ts and exercised the same way, so the side-question path has real runtime proof too.
  • Resolver cases for both paths (including fractional rejection) remain as a fast smoke layer.

Local verification:

pnpm test 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)

node_modules/.bin/tsx scripts/proof/codex-dynamic-tool-timeout-seconds.mts
# All cases passed (resolver + runtime for main and side paths).

@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.

@cxbAsDev
cxbAsDev force-pushed the fix/codex-dynamic-tool-timeout-seconds branch from b5f1255 to 1bf877a Compare July 6, 2026 10:29
@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

CI update after the latest push (1bf877a2d6):

  • ✅ Real behavior proof passes.
  • ✅ Unit tests for the changed Codex paths pass locally and in the Node shards.
  • ✅ Lint for the files this PR touches passes locally.
  • ❌ Several CI checks fail, but they all fail because of the same upstream packages/gateway-protocol/src/index.ts issue, not this PR's changes.

Failing checks all report duplicate identifiers in packages/gateway-protocol/src/index.ts:

packages/gateway-protocol/src/index.ts(1174,8): error TS2300: Duplicate identifier 'SessionWorktreeInfo'.
packages/gateway-protocol/src/index.ts(1177,8): error TS2300: Duplicate identifier 'SessionsCreateResult'.
packages/gateway-protocol/src/index.ts(1544,3): error TS2300: Duplicate identifier 'SessionWorktreeInfo'.
packages/gateway-protocol/src/index.ts(1545,3): error TS2300: Duplicate identifier 'SessionsCreateResult'.

Affected CI jobs: check-lint, check-prod-types, check-test-types, check-additional-extension-bundled, check-additional-extension-channels, check-additional-extension-package-boundary.

I verified this is a pre-existing upstream main breakage: the same duplicate-identifier errors reproduce on a clean upstream/main checkout when running pnpm tsgo:extensions and the extension lint/boundary checks. This PR only touches extensions/codex/src/app-server/* and scripts/proof/codex-dynamic-tool-timeout-seconds.mts; packages/gateway-protocol/src/index.ts is unchanged.

Recommendation: wait for upstream main to be fixed (or a separate PR to resolve the gateway-protocol duplicate exports), then re-run CI here. The proof and tests for #100722 itself are green.

@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Update: I opened #100871 to fix the upstream packages/gateway-protocol/src/index.ts breakage that was causing the CI failures here (check-lint, check-prod-types, check-test-types, check-additional-extension-*). Once #100871 lands, rebasing this PR should give a green CI run.

@openclaw-barnacle openclaw-barnacle Bot removed app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel extensions: memory-core Extension: memory-core cli CLI command changes scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: feishu Channel integration: feishu channel: irc extensions: qa-lab labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Maintainer repair is land-ready at d5f5502fed520132b65fa7e42c80c125bcd3ad17.

Known gap: no credentialed live Codex app-server session was run; upstream protocol inspection and fake-timer regressions cover the exact forwarded argument and structured-timeout ordering contracts.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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.

Dynamic tool hard timeout should honor timeoutSeconds when timeoutMs is absent

2 participants