Skip to content

fix: Claude MCP turns abort before tool timeout - #155663

Merged
VACInc merged 3 commits into
mainfrom
fix/claude-mcp-tool-recovery-deadline
Sep 22, 2026
Merged

VACInc merged 3 commits into
mainfrom
fix/claude-mcp-tool-recovery-deadline

Conversation

@VACInc

@VACInc VACInc commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: Claude CLI can report that it stopped making progress while an OpenClaw MCP tool is still within the managed connection's configured response window.

User Impact

Long-running managed MCP calls can return their result or timeout error to Claude. Explicit cancellation still interrupts the turn, and tools without the managed timeout retain the existing recovery policy.

Why This Change Was Made

The managed Claude MCP config enforces a 3,610,000 ms response timeout, but diagnostic recovery previously saw no execution deadline and applied its ordinary 900,000 ms blocked-tool floor. The prepared run now carries the same managed timeout. A trusted OpenClaw MCP tool-start event publishes that fixed deadline through the existing private liveness channel, whose recovery owner retains the normal 15-minute grace. The timeout remains owned beside Claude's generated MCP configuration; this does not change tool cancellation or the tool's own deadline.

Evidence

Behavior and tests

  • Regression proof: pnpm test src/agents/cli-runner/execute-events.mcp-recovery.test.ts --maxWorkers=1 fails on pre-fix ca97ceb8f9bd712205da7fef9c65eb99c5cc6f45 because activeToolDeadlineAtMs is undefined; on final head c9eec1f6de9e647e4ad631cd24cf176adddbe006, it passes (1 test, 12 ms test time, 29.70 s command wall). At 15 minutes, recovery observes a 4,510,000 ms threshold from tool start instead of reclaiming the turn.
  • Preparation boundary: the existing managed-Claude config test now also proves the prepared run publishes managedMcpToolTimeoutMs. Its exact final-head focused invocation passed (385 ms test time, 9.26 s command wall). The complete changed test file passed 184 tests in 78.19 s before the disjoint current-main refresh; the new assertion adds no test case or runtime fixture to that already broad integration-owner file.
  • node scripts/check-changed.mjs -- <six changed paths> passed on final head, including production and test type graphs, focused lint, formatting, both max-lines ratchets, assertion safety, dead exports, dependency/config/plugin guards, and runtime import cycles. git diff --check also passed.

Required review receipts

  • Test audit: kept the regression because it fails on the original defect and exercises the real parsed CLI event → diagnostic activity → stale-threshold boundary. Added the missing preparation assertion, used fake time, and added no test-only production seam, sleep, polling, worker pin, or Gateway boot.
  • Deslop: moved Claude's managed-timeout config ownership into the existing Claude MCP module, removed duplicated policy from the oversized preparation owner, and found no remaining behavior-neutral slop in the candidate.
  • Flake triage: focused tests passed on their first final-head run. The original hosted failures were deterministic: the branch-local line-cap growth was repaired, while check-prod-types matched red main and was resolved by integrating the canonical current-main declaration fix. No rerun or no-op push was used to turn a red result green.
  • Independent autoreview: P3 whole-candidate review is scoped-clean with no accepted correctness or security findings (0.86 confidence).
  • ClawSweeper: Revision 2 reviewed exact final head c9eec1f6de9e647e4ad631cd24cf176adddbe006, found no correctness or security defects, and listed no “Before merge” items.

Hosted checks

Exact-final-head GitHub CI passed on its first run in 1,111 seconds (11:07:28–11:25:59 UTC). The final openclaw/ci-gate, dependency review, and security-sensitive review all reported success for c9eec1f6de9e647e4ad631cd24cf176adddbe006.

What Was Not Tested

The patched code was not deployed into the live Gateway. A before/after hour-scale external call was not run because the patch only publishes the existing enforced deadline. The separate broker-side serialization delay from the observed incident is outside this PR.

@clawsweeper

clawsweeper Bot commented Sep 22, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 22, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 7:13 AM ET / 11:13 UTC (Revision 2).

ClawSweeper review

What this changes

The PR carries Claude’s existing managed MCP tool timeout into recovery diagnostics so long-running calls are not prematurely aborted.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main, and no introduced correctness or security defect was found. This member-authored, protected PR should remain open for normal landing.

Priority: P2
Reviewed head: c9eec1f6de9e647e4ad631cd24cf176adddbe006

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful reported regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its evidence exercises parsed CLI events through diagnostic recovery and preparation through generated MCP configuration; the body explicitly discloses no live hour-scale Claude run. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its evidence exercises parsed CLI events through diagnostic recovery and preparation through generated MCP configuration; the body explicitly discloses no live hour-scale Claude run. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: Reviewed the complete introduced delta from the pinned base to the original PR head. The change adds deadline propagation and regression coverage while moving the existing timeout configuration into the Claude MCP owner.
Current main still needs the fix: Fetched main emits the parsed tool-start diagnostic without managed timeout metadata, leaving recovery to its ordinary blocked-tool floor. Release-source inspection could not complete because the required blob was unavailable; no shipped-fix claim is made.
Existing recovery owner: The recovery owner already adds a 900,000 ms grace to execution deadlines and converts the resulting absolute deadline into the caller’s evidence-age threshold. The PR reuses that policy without adding another recovery mechanism.
Findings None None.
Security None None.

How this fits together

The CLI runner connects Claude to OpenClaw tools through a managed MCP bridge. Tool-start events feed recovery diagnostics, which decide when an inactive turn can be reclaimed.

flowchart LR
  A[Claude run preparation] --> B[Managed MCP timeout]
  B --> C[Claude tool connection]
  B --> D[Prepared run context]
  C --> E[Parsed tool start]
  D --> E
  E --> F[Recovery deadline and grace]
  F --> G[Wait or reclaim turn]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +27, Tests +85. Total +112 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 42 15 +27
Tests 2 86 1 +85
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 128 16 +112

Review metrics

Metric Value Why it matters
Recovery allowance 900,000 ms floor → 4,510,000 ms from managed tool start Recovery now accounts for the existing 3,610,000 ms response timeout and its existing 15-minute grace.
Production versus test growth production net +27 lines; tests net +85 lines Production growth carries the existing timeout into diagnostics; regression coverage checks that boundary without a new production test seam.

Technical review

Best possible solution:

Keep Claude’s enforced timeout and recovery allowance synchronized through the existing liveness channel while preserving independent cancellation.

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

Yes, source establishes the mismatch: main omits the managed deadline from parsed tool-start diagnostics, permitting recovery at the ordinary 15-minute floor. The body reports a failing-before/passing-after regression; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The patch supplies the missing deadline to the existing recovery owner without changing the configured tool timeout, stored settings, or cancellation path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6e2ac28079b1.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs premature recovery of long-running managed Claude tool calls with a bounded change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its evidence exercises parsed CLI events through diagnostic recovery and preparation through generated MCP configuration; the body explicitly discloses no live hour-scale Claude run. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the complete introduced delta from the pinned base to the original PR head. The change adds deadline propagation and regression coverage while moving the existing timeout configuration into the Claude MCP owner. (src/agents/cli-runner/execute-events.ts:239, c9eec1f6de9e)
  • Current main still needs the fix: Fetched main emits the parsed tool-start diagnostic without managed timeout metadata, leaving recovery to its ordinary blocked-tool floor. Release-source inspection could not complete because the required blob was unavailable; no shipped-fix claim is made. (src/agents/cli-runner/execute-events.ts:227, 6e2ac28079b1)
  • Existing recovery owner: The recovery owner already adds a 900,000 ms grace to execution deadlines and converts the resulting absolute deadline into the caller’s evidence-age threshold. The PR reuses that policy without adding another recovery mechanism. (src/logging/diagnostic-run-activity-snapshot.ts:114, c9eec1f6de9e)
  • Cancellation and cleanup remain independent: Process cancellation still calls the supervisor directly through the caller’s abort signal. Parsed terminal events remove active tool markers, and finalization emits terminal events for unfinished parsed tools; the new deadline is not consulted to authorize execution or cancellation. (src/agents/cli-runner/execute-process.ts:286, c9eec1f6de9e)
  • Focused regression evidence: The new fake-time test exercises parsed tool start through diagnostic delivery and recovery-threshold calculation, asserting a 4,510,000 ms allowance. The captured PR body reports failure before the fix and a final-head pass, plus a preparation-boundary assertion and changed-file checks. These are contributor-reported test results, not reviewer executions or live Claude proof. (src/agents/cli-runner/execute-events.mcp-recovery.test.ts:23, c9eec1f6de9e)
  • Review continuity: The previous completed review retained no findings or published rank-up moves. The event-handler file is unchanged from that reviewed head; subsequent introduced changes consolidate timeout ownership and strengthen the preparation assertion. (src/agents/cli-runner/execute-events.ts:239, c9eec1f6de9e)

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vito Cappello: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-22T10:35:20.124Z sha 6c159f4 :: needs maintainer review before merge. :: none

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 22, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@VACInc
VACInc merged commit e4d2cb0 into main Sep 22, 2026
193 checks passed
@VACInc
VACInc deleted the fix/claude-mcp-tool-recovery-deadline branch September 22, 2026 13:53
vincentkoc added a commit that referenced this pull request Sep 22, 2026
* commit '739e2410702e0b1ad1d17a6dac07ddc0ab6dbebb': (140 commits)
  fix(ui): pause passive polling in hidden tabs (#155617)
  improve(android): keep chat photos outside text bubbles (#155338)
  fix(ui): preserve saved project after discovery failure (#155619)
  feat: compare Kitchen Sink Gateway resource costs (#155734)
  test(gateway): arm clock-jump claim after readiness (#155748)
  chore(ui): refresh control ui locales (#155700)
  fix(ci): join archive placement fixtures before teardown (#155751)
  fix(matrix): keep bot discovery off the Gateway thread (#152122)
  fix(agents): reconcile late requester recovery receipts (#155357)
  test(gateway): guard embeddings HTTP fixture lifetimes
  fix: isolate triage fixture acquisition and cleanup (#155736)
  refactor(sessions): hydrate saved transcripts off thread (#153325)
  fix: Claude MCP turns abort before tool timeout (#155663)
  fix(goals): pause terminal failures and clarify goal states (#155694)
  fix(test): preserve watcher errors when diagnostic capture fails (#155383)
  ci: move native runtime proofs to release validation (#155606)
  fix(auth): decouple compaction from profile rotation (#155204)
  fix(agents): admit compaction outside retired plugin generations (#151232)
  perf(ui): reduce automatic session list refetches (#155705)
  test: avoid unused source repos in release input fixtures (#155733)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
* fix: keep Claude MCP turns alive through tool timeout

* fix: keep managed MCP timeout ownership coherent

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

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

2 participants