Repository navigation
fix(agents): propagate client tool cancellation - #117352
Conversation
|
Codex review: needs maintainer review before merge. What this changesPreserve 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +30. Total +33 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 21, 2026, 3:04 AM ET / 07:04 UTC (Revision 9). |
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.
cfd525f to
700b4b9
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
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.
What Problem This Solves
Fixes cancelled client-hosted tool calls being returned to the model as ordinary tool errors when cancellation uses a
ToolInputErrorreason.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-437normalizes everyToolInputError, 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
e501abf29b6ac219df5196cc44fcfaf9f7bec12c: failed because the prepared call resolved to an error result instead of rejecting with the original cancellation reason.git diff --checkpassed.