Skip to content

fix: name pending tools when the reply watchdog stops a run - #200601

Merged
steipete merged 2 commits into
mainfrom
codex/watchdog-blocked-tool-attribution
Nov 17, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/watchdog-blocked-tool-attribution

Conversation

@steipete

@steipete steipete commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #138528
Related: #191637

What Problem This Solves

A reply stopped by the watchdog reports “Reply operation stalled” without identifying the tool it was waiting for. After abort cleanup, those pending-tool records are gone, so operators cannot recover that attribution from the lane error or automation history.

User Impact

The existing lane-error record now includes staleReason and up to five pendingTools, each containing only toolName, toolCallId, and elapsed milliseconds at the stop. Automation history includes the same identities alongside its recovery classification. Provider rate-limit text and the semantic classification used for alert guidance keep their existing precedence.

Why This Change Was Made

The session-controller watchdog already owns the tool names, call IDs and start times. describeStop() (src/sessions/session-controller.watchdog.ts:438) discarded them when building its abort error. abortForStall() (src/sessions/session-controller.operation.ts:650) already calls it before cleanup, so the fix captures those existing records there, without changing abort ordering or keeping another tracker.

The worker path had a second gap: its tool-surface setup (src/worker/embedded-agent.runtime.ts:317) used the catalog's default executor, which does not publish nested host-call lifecycle events. The worker's live-event owner now adapts catalog start/end events using the existing schema's name and toolCallId; required argument/result slots are null, so this attribution adds no tool content. The Gateway's existing worker-turn-run-owner.ts:232 projection registers the host tool under its own name.

This extends #191637's controller-to-history projection. #138528 remains open: immediate exec-denial classification and the broader approval failure are outside this fix. Correlating the host call with a Code Mode bridgeRequestId still needs an approved protocol field; no schema, timeout, threshold, config or bridge-correlation change is included here.

Evidence

The controller regression queues a run with six pending tool calls that never finish normally, advances the watchdog to its stop, and checks the abort classification and existing lane diagnostic after cleanup. Only the first five tools survive, each with elapsedMs: 900000.

On base 176f2ff9652ea6539192a7c580940ced94b27942, pnpm test src/sessions/session-controller.watchdog.test.ts --maxWorkers=1 failed as intended: 1 failed / 64 passed; pendingTools and staleReason were absent. The fixed regression is green. Code Mode coverage verifies the named host record with Node and QuickJS, the worker catalog-to-live-event adapter, the Gateway receiver, and cron history while retaining the semantic alert cause. These are focused production-owner boundary tests with synthetic tools, not a credentialed model or deployed-worker campaign.

All focused checks passed: 160 tests across six files; core production typecheck and a targeted six-file test typecheck; production/test type-aware lint; formatting; git diff --check; and pnpm build (final run: 2m 26.7s). The build returned zero; its UI bundle-budget advisory listed overages, with no UI source changes in this PR. A separate baseline budget measurement was not run.

Per-file local timing: watchdog owner 65 tests / 56.48s wrapper wall; worker live runtime 18 / 44.74s; Code Mode lifecycle 22 / 18.75s shard wall; cron cause 10 / 9.00s; Gateway worker ownership 15 / 63.63s; command queue 30 / 3.64s. The two new regression cases' single-file runs spend 95–96% of their Vitest duration preparing compiled subprocess artifacts; their test bodies remain below one second. The existing Gateway suite uses real worker/store lifecycle boundaries. The final CI job span was 955s (15m 55s), with results qualified below.

Codex autoreview of the complete local change against 176f2ff9652ea6539192a7c580940ced94b27942, through P2: scoped-clean, no accepted/actionable findings. The reviewer received the unchanged abort operation, recovery owner, and worker receiver as context; it did not independently rerun tests or inspect the unchanged catalog executor contract. The catalog's default execution/acceptance path was separately traced in source and exercised by the focused worker guest regression.

Net test growth: 146 lines, below the 400-line allocation threshold. The production growth is the typed abort error/projection and the worker's missing lifecycle adapter; no parallel state store or tool tracker is added. docs/logging.md documents the diagnostic shape. Release-note context: watchdog abort diagnostics and automation history now name pending tools, including Code Mode host calls on worker turns.

CI Follow-through

The first run, 44091557036, found an assertion-safety documentation gap in the new worker adapter. The worker constructs four-argument host tools, while the shared catalog executor also accepts extension tools with a fifth context argument. A SAFETY comment now explains that existing boundary. The focused assertion-safety ratchet, worker type-aware lint, formatting, and a Codex review of the comment-only repair all pass; no runtime behavior changed.

That run also failed src/gateway/server.sessions.create.forks.test.ts > sessions.create inherits only durable selection: explicit selection: expected absent totalTokens, received 0. The focused command pnpm test src/gateway/server.sessions.create.forks.test.ts --maxWorkers=1 -- -t 'sessions\.create inherits only durable selection: explicit selection' reproduces the identical failure both on the PR and on unchanged base 176f2ff9652ea6539192a7c580940ced94b27942 (one failed, 23 skipped in each). The test and creation owners are unchanged by this PR; src/gateway/session-create-initial-assistant.ts:112 initializes fresh-session totalTokens to zero. This is pre-existing evidence, not a passing replay or a fix to session creation.

Final head e75676862b09b027b1de87982c7b96b016524dde completed 44094575933, attempt 1: 81 terminal jobs, 50 successful, 27 skipped, and four failed (three roots plus their aggregate gate). security-fast and baseline ratchets passed. The job span was 955s.

The three unrelated root failures are independently attributed for the native landing exception:

  • Changed job 2 stopped before tests: build heap 4,297 MB was below the unchanged 4,352 MB minimum.
  • Changed job 5 stopped at the same capacity admission with 4,328 MB. The local full build passed; the missing CI test execution is not claimed passing.
  • Compact changed job 18 repeated the session-creation totalTokens failure reproduced on base above.

CI tested merge 448c2de94157185822b585a92310f574086b77c9, whose ordered parents are main 6e38d6dc714da46ab482a0d6fe6889521ee22644 and this exact PR head. The build admission sources, CI workflow, failing session-creation test, and creation owners have identical Git objects between that main parent and the tested merge. The aggregate gate reports those three roots. Native exception evidence retains the failed attempt, source-object comparison, checkout, logs, and passing scoped proof; CI is not described as green.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@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-17T13:21:47.773414Z bc44c1b 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 gateway Gateway runtime agents Agent runtime and tooling size: M labels Nov 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@steipete
steipete merged commit 3a595d3 into main Nov 17, 2026
142 of 147 checks passed
@steipete
steipete deleted the codex/watchdog-blocked-tool-attribution branch November 17, 2026 14:01
@steipete

Copy link
Copy Markdown
Contributor Author

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

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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant