airflow.providers.common.ai.mixins.cancellable_run¶
Mixin that cancels an operator’s in-flight pydantic-ai run when the task is killed.
Classes¶
Run a pydantic-ai agent synchronously with kill-time cancellation wired in. |
Module Contents¶
- class airflow.providers.common.ai.mixins.cancellable_run.CancellableAgentRunMixin[source]¶
Run a pydantic-ai agent synchronously with kill-time cancellation wired in.
The wrapper holds the in-flight run’s
CancellationTokensoon_kill()can cancel it. Cancelling makesrun_syncraiseRunCancelledand unwind, giving the agent’s toolsets a chance to exit (tearing down a provisioned sandbox, for one) before SIGKILL rather than leaving the run to die mid-flight.This needs the Task SDK to call
on_killon SIGTERM, which lands in Airflow 3.0.4 and 3.1.0. On 3.0.0 to 3.0.3 the handler is absent, so a kill runs the pre-existing path (the run continues until SIGKILL).