Skip to content

feat(copilot): let Run agent cancel workflow runs - #7151

Merged
icecrasher321 merged 20 commits into
stagingfrom
feat/let-mship-cancel-workflow-runs
Sep 1, 2026
Merged

feat(copilot): let Run agent cancel workflow runs#7151
icecrasher321 merged 20 commits into
stagingfrom
feat/let-mship-cancel-workflow-runs

Conversation

@j15z

@j15z j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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 workflowId and executionId, with no fallback to the current workflow context.

Related: simstudioai/mothership#459

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • bun run lint
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging
  • bun run check:audits
  • bun run --cwd apps/sim test -- lib/copilot/tool-executor/router.test.ts lib/copilot/tools/handlers/workflow/mutations.test.ts
  • bun run --cwd apps/sim type-check
  • bun run check:api-validation:strict
  • Focused Vitest coverage for the cancellation service, application use case, internal and v2 routes, and Copilot handler

Post-Deploy Monitoring & Validation

  • For the first 24 hours, the workflow/Copilot on-call should monitor cancellation error counts and logs for workflowId is required, executionId is required, and run-control failures.
  • Healthy behavior: explicit workflow/run pairs reach the canonical cancellation use case; queued, active, and paused runs cancel successfully; existing terminal-run behavior remains unchanged for each surface.
  • Roll back this change if valid calls with both IDs fail unexpectedly or if any cancellation is applied outside the supplied workflow.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable—no UI changes.

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 1, 2026 3:55am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The 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.

  • Adds Copilot cancellation with explicit workflow and execution parameters.
  • Consolidates internal, v2, and Copilot cancellation behavior.
  • Expands paused, resumed, queued, and workflow-group reconciliation coverage.
  • Updates API contracts, generated clients, route policies, and cancellation tests.

Confidence Score: 4/5

The 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

Important Files Changed

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]
Loading

Reviews (18): Last reviewed commit: "fix(execution): stop terminal-race resum..." | Re-trigger Greptile

Comment thread apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts Outdated
Comment thread apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts Outdated
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/execution/cancel-workflow-execution-post-auth.ts Outdated
@j15z
j15z force-pushed the feat/let-mship-cancel-workflow-runs branch from 106a466 to 2a37dbe Compare August 27, 2026 04:35
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/execution/cancel-workflow-execution-post-auth.ts Outdated
Comment thread apps/sim/lib/execution/cancel-workflow-execution-post-auth.ts Outdated
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/execution/cancel-workflow-execution-post-auth.ts Outdated
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z
j15z force-pushed the feat/let-mship-cancel-workflow-runs branch from 4bd0e2a to 00e58f0 Compare August 27, 2026 04:53
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z
j15z force-pushed the feat/let-mship-cancel-workflow-runs branch from 00e58f0 to e6c8777 Compare August 27, 2026 05:35
@j15z

j15z commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/execution/cancel-workflow-execution.ts Outdated
@j15z

j15z commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/execution/cancel-workflow-execution.ts
@cubic-dev-ai

cubic-dev-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

@cubic review

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts
Comment thread apps/sim/lib/workflows/application/cancel-run.ts
@icecrasher321
icecrasher321 force-pushed the feat/let-mship-cancel-workflow-runs branch from 265110c to feccbda Compare September 1, 2026 03:53
@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

Comment thread apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

Comment thread apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts
@icecrasher321
icecrasher321 merged commit 48f72a2 into staging Sep 1, 2026
27 checks passed
@icecrasher321
icecrasher321 deleted the feat/let-mship-cancel-workflow-runs branch September 1, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants