Skip to content

fix(agent-core): skip prepared tool execution after abort#102283

Closed
HOYALIM wants to merge 1 commit into
openclaw:mainfrom
HOYALIM:codex/issue-102252-abort-paid-tools
Closed

fix(agent-core): skip prepared tool execution after abort#102283
HOYALIM wants to merge 1 commit into
openclaw:mainfrom
HOYALIM:codex/issue-102252-abort-paid-tools

Conversation

@HOYALIM

@HOYALIM HOYALIM commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Closes #102252

AI-assisted: yes. I reviewed the change and understand the runtime behavior.

What Problem This Solves

Fixes an issue where a parallel tool batch could still execute a prepared paid or side-effectful tool after the run had already been aborted by another tool preflight.

Why This Change Was Made

The tool loop now checks the abort signal immediately before execute and records executionStarted: false when execution is skipped, so afterToolCall is not invoked for work that never started.

User Impact

Prevents cancelled runs from starting a prepared paid/side-effectful tool after abort, while preserving normal behavior for tools that already started before cancellation.

Evidence

  • pnpm exec oxfmt --check packages/agent-core/src/agent-loop.ts packages/agent-core/src/agent-loop.test.ts -> passed
  • node scripts/run-vitest.mjs packages/agent-core/src/agent-loop.test.ts -> 1 file, 23 tests passed
  • git diff --check -> passed

Signed-off-by: Ho Lim [email protected]

Copilot AI review requested due to automatic review settings July 8, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the same agent-core abort fix is already represented by the open proof-sufficient canonical PR, and this branch has no unique required remainder beyond weaker duplicate test/proof coverage.

Root-cause cluster
Relationship: superseded
Canonical: #102276
Summary: This PR is a duplicate candidate for the prepared parallel-tool abort race; the sibling PR is the proof-positive canonical landing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Land #102276 as the canonical proof-positive fix for #102252, then close this duplicate branch.

So I’m closing this here and keeping the remaining discussion on #102276 and #102252.

Review details

Best possible solution:

Land #102276 as the canonical proof-positive fix for #102252, then close this duplicate branch.

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

Yes, at source level. Current main defers prepared parallel tool calls and lacks a pre-execute abort guard, while the linked issue and both candidate tests exercise aborting during beforeToolCall.

Is this the best way to solve the issue?

No, this PR is not the best landing path. The runtime fix shape is right, but #102276 carries the same fix with stronger real behavior proof and stronger regression assertions.

Security review:

Security review cleared: The diff only changes internal agent-core cancellation logic and colocated tests; it adds no dependency, workflow, secret, install, publishing, or supply-chain surface.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • vincentkoc: Current blame attributes the packaged agent-loop.ts, agent-loop.test.ts, and agent.ts surfaces, including the prepared parallel execution path, to recent agent-core extraction work. (role: recent area contributor; confidence: high; commits: 5a5b4c5b105f, e085fa1a3ffd; files: packages/agent-core/src/agent-loop.ts, packages/agent-core/src/agent-loop.test.ts, packages/agent-core/src/agent.ts)
  • steipete: History on the predecessor steering loop shows earlier agent loop queue and typing work before the packaged agent-core extraction. (role: earlier agent-loop contributor; confidence: medium; commits: 44339a644761, 0f271ab535c9, b635e8365135; files: src/agents/steerable-agent-loop.ts)
  • szsip239: Authored the merged adjacent abort-loop PR that changed the same loop and test surface for a distinct post-tool abort continuation bug. (role: adjacent abort behavior contributor; confidence: medium; commits: 7fe287b0d30d; files: packages/agent-core/src/agent-loop.ts, packages/agent-core/src/agent-loop.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 0307deacfac7.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 Jul 8, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 8, 2026
@HOYALIM
HOYALIM force-pushed the codex/issue-102252-abort-paid-tools branch from b1a7838 to 1135276 Compare July 9, 2026 01:40
@HOYALIM
HOYALIM force-pushed the codex/issue-102252-abort-paid-tools branch from 1135276 to 8dab330 Compare July 9, 2026 01:54
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Superseded by #102276, now merged as 85aa26d34f8b190d9d27d23966391dc616dc4b0c.

The landed fix places the same abort guard at the centralized prepared-tool execution boundary, preserves executionStarted: false through lifecycle events, skips afterToolCall for calls that never ran, and includes focused parallel-batch regression coverage. Exact-head CI passed: https://github.com/openclaw/openclaw/actions/runs/29005460560

Thank you for independently identifying and fixing the race.

@steipete steipete closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent-core: parallel batch runs a prepared paid tool after the run is aborted mid-batch

3 participants