How It Works
Thecancel_run() function records cancellation intent for a run. Agent, team, and workflow runs stop when they reach the next cooperative cancellation checkpoint. An operation already in progress may finish, and cancellation does not roll back external side effects.
Cancellation Behavior:
- Non-Streaming Runs: The
RunOutputobject is returned with status set toRunStatus.cancelled. - Streaming Runs: A
RunCancelledEventis emitted when cancellation occurs. Workflows emit aWorkflowCancelledEvent.
Cancellation Methods
Agent Run Cancellation
Cancel agent runs programmatically or via API endpoints.
Team Run Cancellation
Cancel team runs and handle member run cancellations.
Workflow Run Cancellation
Cancel workflow executions and manage step-level cancellation.