Skip to content

workflow: implement Run.terminate() - #396

Merged
fantix merged 3 commits into
mainfrom
feat/workflow-run-cancel
Sep 21, 2026
Merged

fantix merged 3 commits into
mainfrom
feat/workflow-run-cancel

Conversation

@fantix

@fantix fantix commented Sep 15, 2026

Copy link
Copy Markdown
Member

Add await run.terminate() with an optional reason, recorded as plaintext on a run_cancelled event with a limit of 512 UTF-16 code units.

This is the TS SDK's Run.cancel(), renamed to reserve cancel() for cooperative cancellation. We've been missing this one until I found it during docs work.

Write cancellation events with an optional reason and model the event so cancellation responses and stored events can be read.

@msullivan msullivan 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.

Hm; would it be possible to come up with a modified name for this?

Maybe it would be better if we kept cancel meaning python task cancellation; you could imagine us making it work on workflows runs too.

Feel free to ignore me and merge if you think that's ridiculous

Comment thread src/vercel-workflow/vercel/workflow/_internal/world.py Outdated
Reuse UTF-16 code unit counting for cancellation reasons and attribute
keys.
@fantix

fantix commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Maybe it would be better if we kept cancel meaning python task cancellation; you could imagine us making it work on workflows runs too.

Yeah this makes sense; since TS is already using "abort" for interrupting steps cooperatively, I would rename this to "terminate" as in "kill workflow run from outside without cleanup". We still have a chance to rename before release if you found "terminate" a bad name too.

Reserve cancel for future cooperative cancellation. Document that
termination marks the run cancelled without delivering CancelledError
to the workflow or its running steps.
@msullivan

Copy link
Copy Markdown
Contributor

Maybe it would be better if we kept cancel meaning python task cancellation; you could imagine us making it work on workflows runs too.

Yeah this makes sense; since TS is already using "abort" for interrupting steps cooperatively, I would rename this to "terminate" as in "kill workflow run from outside without cleanup". We still have a chance to rename before release if you found "terminate" a bad name too.

Terminate sounds good to me.

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