Skip to content

fix(agents): propagate client tool cancellation - #117352

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-agent-tool-cancellation-boundary
Oct 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-agent-tool-cancellation-boundary

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes cancelled client-hosted tool calls being returned to the model as ordinary tool errors when cancellation uses a ToolInputError reason.

User Impact

Cancellation propagates to the owning run, the reserved client call is discarded, and the client is never asked to execute it. Ordinary invalid arguments still produce a visible tool error.

Why This Change Was Made

On current main, src/agents/agent-tool-definition-adapter.ts:431-437 normalizes every ToolInputError, including the original cancellation reason thrown by the source guard after execution preparation. Preserve cancellation before that normalization, matching the local adapter's error handling.

Current main already checks source authority after the asynchronous preparation pause, so the old post-hook barriers and their redundant coverage were removed. The remaining change uses the existing guard and reservation owner: production +3/-0 lines; tests +30/-0 lines.

Evidence

  • Regression on unchanged production at e501abf29b6ac219df5196cc44fcfaf9f7bec12c: failed because the prepared call resolved to an error result instead of rejecting with the original cancellation reason.
  • Fixed adapter suite: 27/27 passed, including reservation cleanup, no client completion, and existing ordinary input-error controls. The new regression took 3 ms; Vitest reported 262.63 seconds (443.94 seconds including runner setup/cleanup), dominated by cold compilation. The focused base reproduction reported 477.19 seconds (588.86 seconds including setup/cleanup) under shared host load.
  • Targeted oxlint, oxfmt, and git diff --check passed.
  • Simplification pass and independent Codex autoreview through P2: no actionable findings.
  • No live Gateway or client was exercised, per the repair lane's scoped-proof instruction. Exact-head PR CI supplies the broad validation before the separate landing decision.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve cancelled client-tool failures instead of formatting them as ordinary input errors.

Example: A prepared search call with query "example" is cancelled with ToolInputError("client tool cancelled") before launch.

  • Before: The reserved call is discarded, but execution resolves to an ordinary tool-error result.
  • After: The reserved call is discarded and execution rejects with the original cancellation reason without completing client delegation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is correct and exact-head CI passes; behavioral confidence rests on source inspection and the reported in-process regression.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal repair is outside the external contributor proof gate; supplied evidence reports a base-red/head-green adapter regression, not a shipped-entry-point run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A cancelled client-hosted tool call can be reported to the model as an ordinary argument error instead of propagating cancellation.
Reason: The maintainer-authored direction restores existing cancellation semantics with a narrowly scoped repair and preserves ordinary invalid-argument errors.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current cancellation-handling defect with a focused change and no actionable findings. Both earlier preparation-boundary findings are resolved, and the exact-head CI gate now passes.

Priority: P2
Reviewed head: 700b4b9cf0c2abc8163d296226ca5b5a25365a70

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No live Gateway or client was exercised; the supplied regression covers the production adapter and preparer boundary.
Agent review details

How this fits together

The agent tool adapter receives model tool arguments and run cancellation, applies hooks and execution preparation, then either records client delegation or returns an error to the owning runtime.

flowchart LR
A[Agent tool call] --> B[Argument validation and hooks]
B --> C[Execution preparation]
C --> D[Current source guard]
D --> E[Client delegation]
D --> F[Failure cleanup]
F --> G[Cancellation rejection or input error]
Loading

Technical review

Best possible solution:

Retain the existing source guard and reservation owner while propagating cancellation before input-error formatting.

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

The source gives a deterministic reproduction: prepare a client call, abort with ToolInputError, then launch it; current main catches the guard's rejection and formats it as an input error. The PR reports this regression failing on the base and passing on the head; no target code was executed during this review.

Is this the best way to solve the issue?

This is the smallest complete repair: preserve the original rejection after existing cleanup, matching the local adapter without adding another cancellation owner or execution barrier.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a8523bc adds src/agents/agent-tool-definition-adapter.ts:567 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a8523bcecd0e; files: src/agents/agent-tool-definition-adapter.ts)
  • Josh Avant: Raw commit bc3092f adds src/agents/agent-tool-definition-adapter.ts:431 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc3092fceb5d; files: src/agents/agent-tool-definition-adapter.ts)

PR surface

Source +3, Tests +30. Total +33 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 1 30 0 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 33 0 +33

Review metrics

Metric Value Why it matters
Production versus regression coverage production +3/-0; tests +30/-0 The small production change reuses existing cancellation and cleanup owners; one regression distinguishes cancellation from ordinary input validation.

Labels

Label changes:

  • add P2: A specific cancellation-reason type is misreported as a tool input error; existing guards already prevent client delegation.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A specific cancellation-reason type is misreported as a tool input error; existing guards already prevent client delegation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; 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.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-01T11:02:22.573Z sha cfd525f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T15:05:21.353Z sha cfd525f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T15:17:37.644Z sha cfd525f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T19:00:16.170Z sha cfd525f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T23:51:44.194Z sha cfd525f :: needs real behavior proof before merge. :: none
  • reviewed August 4, 2026, 11:19 AM ET / 15:19 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed August 8, 2026, 7:45 AM ET / 11:45 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T16:14:16.673Z sha cfd525f :: found issues before merge. :: [P1] Recheck cancellation after local preparer release | [P1] Recheck cancellation after client preparer release

Reviewed October 21, 2026, 3:04 AM ET / 07:04 UTC (Revision 9).

@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. 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 Aug 8, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 17, 2026
Preserve cancellation before normalizing client ToolInputError results. Current source guards already reject cancelled prepared calls; keep reservation cleanup and propagate the original failure to the run.
@steipete
steipete force-pushed the codex/qa400-agent-tool-cancellation-boundary branch from cfd525f to 700b4b9 Compare October 21, 2026 06:53
@steipete steipete changed the title fix(agents): preserve cancellation at tool execution boundary fix(agents): propagate client tool cancellation Oct 21, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. P2 Normal backlog priority with limited blast radius. labels Oct 21, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Oct 21, 2026
@steipete
steipete merged commit d5f6417 into main Oct 21, 2026
143 of 145 checks passed
@steipete
steipete deleted the codex/qa400-agent-tool-cancellation-boundary branch October 21, 2026 15:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
Preserve cancellation before normalizing client ToolInputError results. Current source guards already reject cancelled prepared calls; keep reservation cleanup and propagate the original failure to the run.
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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