feat(copilot): let Run agent cancel workflow runs - #7151
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR centralizes workflow-run cancellation behind a shared authorized application use case and exposes it to the Run agent while preserving surface-specific terminal behavior.
Confidence Score: 4/5The PR is not yet safe to merge because a mismatched workflow/execution pair can cancel the execution belonging to a different workflow instead of being rejected. The new contract requires both identifiers, but every changed adapter passes only the execution ID and the shared use case resolves the canonical workflow without asserting the supplied workflow ID. Files Needing Attention: apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts, apps/sim/lib/workflows/application/cancel-run.ts, and both cancellation route adapters
|
| Filename | Overview |
|---|---|
| apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts | Delegates Run-agent cancellation to the shared use case, but drops the newly required workflowId and therefore does not enforce the workflow/execution pair. |
| apps/sim/lib/workflows/application/cancel-run.ts | Provides the shared authorization and cancellation boundary, but resolves cancellation only by runId without asserting the caller-supplied workflow. |
| apps/sim/lib/execution/cancel-workflow-execution.ts | Implements expanded cancellation and reconciliation across queued, active, paused, resumed, and workflow-group executions. |
| apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts | Adds transactional paused-run cancellation, rollback, terminal-race, and resume-finalization transitions. |
| apps/sim/app/api/v2/workflows/[workflowId]/runs/[runId]/cancel/route.ts | Adopts the shared cancellation use case and v2-specific terminal policy, but discards the workflow-scoped path parameter. |
| apps/sim/app/api/workflows/[id]/executions/[executionId]/cancel/route.ts | Reduces the internal route to authentication and presentation, but does not forward the workflow ID for run-binding validation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
C[Copilot cancellation] --> A[Cancellation adapter]
I[Internal cancellation route] --> A
V[v2 cancellation route] --> A
A --> U[cancelWorkflowRun]
U --> R[Resolve execution and canonical workflow]
R --> Z[Authorize canonical workspace]
Z --> X[Cancel queued, active, paused, or grouped execution]
Reviews (18): Last reviewed commit: "fix(execution): stop terminal-race resum..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
106a466 to
2a37dbe
Compare
4bd0e2a to
00e58f0
Compare
00e58f0 to
e6c8777
Compare
@icecrasher321 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 31 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
Fix all with cubic | Re-trigger cubic
265110c to
feccbda
Compare
Summary
The Run agent can now cancel workflow runs by workflow and execution ID. Internal, Copilot, and v2 callers share the same authorized cancellation operation without changing the public v2 terminal no-op contract.
Cancellation remains consistent for queued, active, paused, resumed, and workflow-group executions. Internal and Copilot callers continue to receive conflicts for completed or failed runs, while v2 returns its existing successful no-op response. The Copilot handler now matches the v2 contract by requiring both
workflowIdandexecutionId, with no fallback to the current workflow context.Related: simstudioai/mothership#459
Type of Change
Testing
bun run lintbun run apps/sim/scripts/check-block-registry.ts origin/stagingbun run check:auditsbun run --cwd apps/sim test -- lib/copilot/tool-executor/router.test.ts lib/copilot/tools/handlers/workflow/mutations.test.tsbun run --cwd apps/sim type-checkbun run check:api-validation:strictPost-Deploy Monitoring & Validation
workflowId is required,executionId is required, and run-control failures.Checklist
Screenshots/Videos
Not applicable—no UI changes.