fix(agent-core): stop canceled parallel tools from starting#102276
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 8, 2026, 4:01 PM ET / 20:01 UTC. Summary PR surface: Source +10, Tests +77. Total +87 across 2 files. Reproducibility: yes. at source level. Current main defers prepared parallel calls through Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land one narrow agent-core pre-execute abort guard with regression coverage, preferably this proof-positive branch unless maintainers intentionally choose the duplicate candidate. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main defers prepared parallel calls through Is this the best way to solve the issue? Yes. The shared pre-execute guard in AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b81666ca6af2. Label changesLabel justifications:
Evidence reviewedPR surface: Source +10, Tests +77. Total +87 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (3 earlier review cycles) |
|
@clawsweeper re-review Updated the PR body with source-checkout proof outside Vitest. The proof drives real |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer review and fixup complete; this is land-ready.
No known proof gaps. Release-note context: parallel tool cancellation now prevents prepared side-effectful calls from starting after a later preflight abort; |
|
Merged via squash.
|
…#102276) * fix(agent-core): skip prepared tools after abort * docs(agent-core): explain parallel abort guard * docs(changelog): note parallel cancellation fix * docs(changelog): leave release notes release-owned --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #102252
What Problem This Solves
Fixes an issue where users canceling a run during a parallel tool batch could still have an already-prepared paid tool start afterward when another tool was still in its pre-execution hook.
Why This Change Was Made
The agent loop now re-checks the abort signal immediately before a prepared tool is allowed to execute. If the run was canceled after preparation but before execution, the prepared call is finalized as aborted with
executionStarted: false, and post-tool hooks are not invoked for work that never actually started.This keeps the cancellation boundary in agent-core instead of relying on every individual paid tool to honor abort signals correctly.
AI-assisted implementation.
User Impact
Canceling a run during parallel tool preparation no longer starts stale prepared tool work afterward. This prevents unnecessary provider calls for tools that may dispatch paid jobs when
executebegins.Evidence
231812d76644c1908b5aa8a4b1de298293e863b6(fix(agent-core): skip prepared tools after abort).scripts/run-vitest.mjs packages/agent-core/src/agent-loop.test.ts -- --reporter=verbosepassed: 1 file, 23 tests.runAgentLoopwith two parallel tool calls, aborts from the second call'sbeforeToolCall, and asserts the already-prepared first call never executes, emitsexecutionStarted: false, and does not runafterToolCall.231812d76644c1908b5aa8a4b1de298293e863b6, I ran a standalonetsxharness that imports the source checkout's realpackages/agent-core/src/agent-loop.tsandcreateAssistantMessageEventStream, then drives the canceled parallel batch directly. Thepaid_style_toolis a local paid-boundary stub: if paid-style dispatch begins, itsexecutecounter increments.paidStyleToolExecuteInvocationsis0,afterToolCallInvocationsis0, and both finalized tool calls haveexecutionStarted: false.git diff --checkandgit diff --cached --checkpassed..agents/skills/autoreview/scripts/autoreview --mode localpassed clean with no accepted/actionable findings.