airflow.providers.common.ai.policies.decision

The decision policy an LLM operator applies to the model’s answer, and the branch options it chooses from.

DecisionPolicy says when the operator may act on the answer by itself and what happens when it may not. BranchOption describes one branch of LLMBranchOperator and lets it demand a different confidence than the policy’s. Both are plain configuration: the operator keeps them as attributes and builds the model-facing types at run time.

Attributes

UncertainAction

UNCERTAIN_ACTIONS

Classes

DecisionPolicy

When an LLM operator may act on the model's answer by itself, and what happens when it may not.

BranchOption

One branch the model may pick: what choosing it means, and the confidence it needs.

Functions

check_bar(value, label)

Validate one confidence bar: a number from 0 to 1, returned as a float.

Module Contents

airflow.providers.common.ai.policies.decision.UncertainAction[source]
airflow.providers.common.ai.policies.decision.UNCERTAIN_ACTIONS: tuple[UncertainAction, ...] = ('review', 'fail')[source]
airflow.providers.common.ai.policies.decision.check_bar(value, label)[source]

Validate one confidence bar: a number from 0 to 1, returned as a float.

class airflow.providers.common.ai.policies.decision.DecisionPolicy[source]

When an LLM operator may act on the model’s answer by itself, and what happens when it may not.

Parameters:
  • min_confidence – The confidence, from 0 to 1, the answer needs for the operator to act without a person. None (default) is no gate: the operator behaves as it always has. Confidence comes from models that report one, such as a classifier model (TypeSafe’s), in provider_details. A model that reports none counts as under the bar, so swapping the connection to a text model does not silently switch off a control the author set.

  • on_uncertain – What happens under the bar. "review" (default) sends the answer to human review through the same approval flow as require_approval, which needs Airflow 3.1+; "fail" fails the task with LowConfidenceError. Inert without min_confidence. require_approval=True on the operator always wins and asks a person whatever the confidence.

min_confidence: float | None = None[source]
on_uncertain: UncertainAction = 'review'[source]
__post_init__()[source]
property gates: bool[source]

Whether a bar is set at all.

property reviews: bool[source]

Whether an uncertain answer opens a human review (as opposed to failing the task).

class airflow.providers.common.ai.policies.decision.BranchOption[source]

One branch the model may pick: what choosing it means, and the confidence it needs.

The value of LLMBranchOperator’s branches mapping, keyed by downstream task ID. A bare string in that mapping is shorthand for BranchOption(description=...).

Parameters:
  • description – What selecting this branch means: its scope and its boundary cases. Sent to the model in the output schema next to the option, so the model reads the option together with its meaning rather than guessing from the task ID. Supports Jinja templating. None presents the branch by its task ID alone.

  • min_confidence – A bar for this branch that differs from the DecisionPolicy’s, so a branch whose wrong pick costs more can demand more certainty. Needs a policy bar to differ from; None inherits it.

description: str | None = None[source]
min_confidence: float | None = None[source]
template_fields: ClassVar[collections.abc.Sequence[str]] = ('description',)[source]
__post_init__()[source]

Was this entry helpful?