fix(runtime-core): avoid MCP tool discovery after agent cancellation (#450) - #457
fix(runtime-core): avoid MCP tool discovery after agent cancellation (#450)#457tkislan wants to merge 2 commits into
Conversation
Add abort checks after MCP client creation and tool discovery so cancelled agent runs skip merging tool sets. Expose optional signal on ExecutionOptions and document the agent-only contract in README.
…450 Add MCP cancellation race tests in execute-agent-block.test.ts and ExecutionEngine signal pass-through / failed-block summary tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe execution engine now accepts an optional Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR changes runtime cancellation behavior and adds related tests and documentation; no actionable merge-blocking risk remains based on the supplied evidence. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #457 +/- ##
=======================================
Coverage 88.30% 88.30%
=======================================
Files 191 191
Lines 10697 10699 +2
Branches 2996 2996
=======================================
+ Hits 9446 9448 +2
Misses 1249 1249
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #450
Problem
When an agent run is cancelled while MCP clients are still being created or while
client.tools()is in flight, the handler continued into tool discovery and/or model streaming after the abort signal had already fired.Changes
agent-handler.tscontext.signal?.throwIfAborted()after retaining fulfilled MCP clients fromPromise.allSettled, before checking for creation failures (abort wins over spawn errors).client.tools()completes, before constructing the agent and starting the model stream.finallycleanup is unchanged.execution-engine.tsExecutionOptions.signalforwarded only toAgentBlockContext.signal.runProject/runFilestill resolve with a failed agent block when the signal aborts.Tests
createMCPClientand pendingclient.tools().failedBlocks === 1.Docs
signalinpackages/runtime-core/README.md.Verification
pnpm exec vitest run packages/runtime-core/src/execute-agent-block.test.ts packages/runtime-core/src/execution-engine.test.tspnpm testpnpm typecheckpnpm biome:checkSummary by CodeRabbit
New Features
Documentation