Airflow Summit 2026 is coming August 31 - September 2 in Austin, TX. Register now to secure your spot!

airflow.providers.common.ai.mixins.approval

Attributes

log

Classes

DeferForApprovalProtocol

Protocol for defer for approval mixin.

LLMApprovalMixin

Mixin that pauses an operator for human review before returning output.

Module Contents

airflow.providers.common.ai.mixins.approval.log[source]
class airflow.providers.common.ai.mixins.approval.DeferForApprovalProtocol[source]

Bases: Protocol

Protocol for defer for approval mixin.

approval_timeout: datetime.timedelta | None[source]
allow_modifications: bool[source]
prompt: str[source]
task_id: str[source]
defer: Any[source]
class airflow.providers.common.ai.mixins.approval.LLMApprovalMixin[source]

Mixin that pauses an operator for human review before returning output.

When require_approval=True on the operator, the generated output is presented to a human reviewer via the Airflow Human-in-the-Loop (HITL) interface. The task waits (awaiting_input on Airflow 3.3+, deferred on older versions) until the reviewer approves or rejects.

If allow_modifications=True, the reviewer can also edit the output before approving. The (possibly modified) output is then returned as the task result.

Operators that use this mixin must set the following attributes:

  • require_approval (bool)

  • allow_modifications (bool)

  • approval_timeout (timedelta | None)

  • prompt (str)

APPROVE = 'Approve'[source]
REJECT = 'Reject'[source]
defer_for_approval(context, output, *, subject=None, body=None)[source]

Write HITL detail, then pause the task for human review.

On Airflow 3.3+ the task parks in the awaiting_input state (no trigger or triggerer involved); on older versions it defers to HITLTrigger. Either way it resumes in execute_complete once a response (or timeout default) arrives.

Parameters:
  • context (airflow.sdk.Context) – Airflow task context.

  • output (Any) – The generated output to present for review.

  • subject (str | None) – Headline shown on the Required Actions page. Defaults to "Review output for task `<task_id>`".

  • body (str | None) – Markdown body shown below the headline. Defaults to the prompt and output wrapped in a code block.

execute_complete(context, generated_output, event)[source]

Resume after human review.

Called automatically by Airflow when the HITL trigger fires. Returns the original or reviewer-modified output on approval.

Parameters:
  • context (airflow.sdk.Context) – Airflow task context.

  • generated_output (str) – The output that was deferred for review.

  • event (dict[str, Any]) – Trigger event payload containing chosen_options, params_input, and responded_by_user.

Raises:
  • HITLRejectException – If the reviewer rejected the output.

  • HITLTriggerEventError – If the trigger reported an error.

  • HITLTimeoutError – If the approval timed out.

Was this entry helpful?