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
265110c to
feccbda
Compare
…ector resolution Rebasing onto origin/staging carried staging's lib/copilot work into our renamed lib/mothership files via rename detection; this finishes what the replay left incomplete: - Complete the #7151 port: cancel_workflow_run handler + registration on the mothership executor (types, tests, and catalog entry had already rename-followed in). - pickRunBlockOutputs awaits the now-async resolveOutputIds (#7346 made selector resolution child-workflow-aware) and re-imports isValidUuid. - Slack execution stream + tool-call-lifecycle import getToolDisplayTitle from the mothership tool-display module (#7296 semantics kept). - Resolve leftover conflict markers from the first replay's failed batch checkout (browser-tool hardening #7311, YAML bounds #7319 kept). - Drop the obsolete lib/mothership/tools/server/blocks scan root: the block-metadata tool died in the dead-code sweep; blocks reads flow through the already-guarded v2 blocks routes. - Regenerate OpenAPI, CLI API, and CLI docs from the merged contracts. Claude-Session: https://claude.ai/code/session_01CgaxNAaeD3taGdghbXn17w
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.