How It Works
Thecancel_run() function marks a run for cancellation. Execution stops gracefully once the current step completes, ensuring that operations finish cleanly without leaving resources in an inconsistent state.
Cancellation Behavior:
- Non-Streaming Runs: The
RunOutputobject is returned with status set toRunStatus.cancelled. - Streaming Runs: A
RunCancelledEventis emitted when cancellation occurs.