Skip to content

fix: let silent Code Mode commands reach their own timeout - #200670

Merged
steipete merged 1 commit into
mainfrom
codex/codemode-exec-deadline
Nov 17, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/codemode-exec-deadline

Conversation

@steipete

@steipete steipete commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #200601, #200647.

What Problem This Solves

In release a117ca5 on November 17, eleven sandboxed Code Mode turns were aborted after 15 minutes without activity. A silent sandbox exec could still be within its default 1,800-second timeout when the reply watchdog terminated the whole turn; three consecutive retries reproduced the same outcome.

User Impact

In-process Code Mode host calls retain the tool execution owner's deadline, allowing a silent command to finish or return its own timeout to guest code. No configuration or watchdog thresholds change.

The worker path still lacks per-tool deadline transport. Its Gateway projection uses the enclosing execution deadline; completing that path requires a protocol schema change, deliberately excluded from this PR.

Why This Change Was Made

Catalog preparation now rebinds the admitted run context through the existing hook rewrap operation, including tools that already have a hook wrapper. It preserves the original hook context and wrapper metadata while giving the nested invocation its watchdog owner.

Deadline ownership and scope

Direct exec already publishes the supervisor's enforced process deadline at src/agents/bash-tools.exec-runtime.ts:699. Direct admission supplies the watchdog attempt through src/agents/harness/tool-authority.runtime.ts:308–314; the tool hook consumes it at src/agents/agent-tools.before-tool-call.wrapper.ts:253–255. The liveness owner binds the live deadline getter to beginTool at src/infra/diagnostic-tool-execution-liveness.ts:56–62. The existing watchdog honors that deadline plus its quiet allowance at src/sessions/session-controller.watchdog.ts:588–595; there is no blanket 15-minute cap.

For in-process Code Mode, src/agents/embedded-agent-runner/run/attempt-tool-prepare.ts:461–463 captures the explicit watchdog owner. Before this change, src/agents/tool-search-catalog.ts:195–196 skipped already wrapped tools, discarding that context. When the guest bridge dispatched without the original ambient caller frame, the host exec's deadline carrier had no watchdog record, leaving the outer Code Mode exec to expire at 900 seconds. The fix is at this existing catalog boundary; it adds no parallel deadline tracker. Accepted existing edge: once a failed host call settles, the existing semantic-stall policy resumes; this patch does not add an allowance for delayed guest/model settlement.

The worker catalog executor added by #200601 forwards host name/callId start/end events at src/worker/embedded-agent-live.runtime.ts:369–389. packages/gateway-protocol/src/schema/worker-admission.ts:358–382 is a closed tool-event schema without a deadline field, and src/gateway/worker-environments/worker-turn-run-owner.ts:231–236 projects the whole execution deadline. Those files and the schema remain unchanged.

The abandoned-call lane (#200647) owns cancellation in src/worker/worker-gateway-tools.ts. The file-queue abort lane owns the keyed queue, file mutation queue and sandbox read/fs adapters. This PR touches none of their files and is rebased on the landed worker cancellation change.

Simplification: reuse the existing context rewrap rather than adding deadline state or changing watchdog policy. Against the base: +5 net production lines, +65 test lines, +5 documentation lines. The test growth is one regression through the actual guest bridge and subscribed executor, covering a boundary existing exec-liveness tests did not exercise.

Evidence

One fake-timer regression runs a guest callValue against a silent host exec-like tool with a real 1,800-second timer and published execution deadline. The base aborts with Reply operation stalled / no_activity at the quiet-tool window. With the fix, the turn survives 900 seconds, the tool's own timeout reaches the guest, and guest code continues successfully.

  • Reproduction: pnpm test src/agents/code-mode.bridge.lifecycle.test.ts --maxWorkers=1 -- -t 'preserves a silent host exec deadline' — red on base, green with the fix.
  • Touched and consumer tests: pnpm test src/agents/code-mode.bridge.lifecycle.test.ts src/agents/tool-search.test.ts src/agents/tool-search-catalog-reuse.test.ts src/agents/agent-tools.prefix-stability.test.ts src/agents/bash-tools.exec-liveness.test.ts --maxWorkers=1 — 5 files, 99 tests passed.
  • Production core and targeted test typechecks, targeted type-aware lint, formatting and git diff --check passed.
  • pnpm build passed.
  • Codex autoreview of the complete local patch against 235e38488bf2cac52d29ffde71c7e066b69f1649, P0–P2: scoped-clean, no accepted/actionable findings. The subsequent rebase preserves the patch; CI verifies the published head.

CI run 44115757625 has an unrelated failure in checks-node-changed-1: code-mode-swarm.test.ts / “reuses a registered collector for the same invocation without double-spawn.” The exact case also fails locally with this PR’s production change removed: the spawn fixture receives an undefined replay key at lines 684–686. Its swarm/runtime/spawn/validation sources are unchanged, and the fixture supplies no hook context, so the modified catalog branch is not selected. This is recorded as an inherited failure; no CI rerun or unrelated repair is claimed.

Release-note context: prevent silent in-process Code Mode exec calls from losing the reply before their own timeout.

Bind the admitted run hook context when cataloging already wrapped tools, preserving the execution owner deadline for silent nested commands. Keep reply watchdog policy unchanged. Add a guest bridge regression proving the 900-second window and delivery of the host timeout at 1800 seconds.
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T15:35:51.157882Z b89f8e8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Nov 17, 2026
@steipete
steipete enabled auto-merge (squash) November 17, 2026 15:42
@steipete
steipete disabled auto-merge November 17, 2026 15:47
@steipete
steipete merged commit eb768cb into main Nov 17, 2026
130 of 135 checks passed
@steipete
steipete deleted the codex/codemode-exec-deadline branch November 17, 2026 15:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
Bind the admitted run hook context when cataloging already wrapped tools, preserving the execution owner deadline for silent nested commands. Keep reply watchdog policy unchanged. Add a guest bridge regression proving the 900-second window and delivery of the host timeout at 1800 seconds.
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
Bind the admitted run hook context when cataloging already wrapped tools, preserving the execution owner deadline for silent nested commands. Keep reply watchdog policy unchanged. Add a guest bridge regression proving the 900-second window and delivery of the host timeout at 1800 seconds.

(cherry picked from commit eb768cb)

Co-authored-by: RomneyDa <[email protected]>

Release adaptation: none; source change applies to the pinned beta baseline.

Follow-up disposition: bounded pinned-main same-path audit recorded in the lane report; cross-lane changes remain parent-owned.

(cherry picked from commit bd9b08ccbf6338bb667e6f1d5081dc69e888c2f3)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
Release adaptation: fix the missing existing wrapper import in the #200670 regression so the release proof exercises the intended deadline behavior. Upstream eb768cb also omits this import.

Follow-up disposition: test-only correction; no additional runtime owner or policy.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 67b0c109103b41228e6fd8070e05a0b27bf421dd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant