> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc-agui.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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 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 `RunOutput` object is returned with status set to `RunStatus.cancelled`.
* **Streaming Runs**: A `RunCancelledEvent` is emitted when cancellation occurs.

## Cancellation Methods

<CardGroup cols={3}>
  <Card title="Agent Run Cancellation" icon="user-astronaut" iconType="duotone" href="/run-cancellation/agent-cancel-run">
    Cancel agent runs programmatically or via API endpoints.
  </Card>

  <Card title="Team Run Cancellation" icon="users" iconType="duotone" href="/run-cancellation/team-cancel-run">
    Cancel team runs and handle member run cancellations.
  </Card>

  <Card title="Workflow Run Cancellation" icon="diagram-project" iconType="duotone" href="/run-cancellation/workflow-cancel-run">
    Cancel workflow executions and manage step-level cancellation.
  </Card>
</CardGroup>
