Skip to main content
You can cancel a running agent by using the agent.cancel_run() function on the agent. Below is a basic example that starts an agent run in a thread and cancels it from another thread, simulating how it can be done via an API. This is supported via AgentOS as well.
For a more complete example, see Cancel a run.