Cancelling a Run
Cancel running agent, team, or workflow executions.
Run cancellation provides the ability to stop running agent, team, or workflow executions. This feature is useful for managing long-running operations, implementing timeouts, or allowing users to interrupt processes.
How It Works
The cancel_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.