airflow.providers.common.ai.utils.validation

Validation helpers for common.ai decorators.

Functions

validate_prompt(value, *, decorator_name)

Validate the prompt returned by a decorator's python_callable.

reject_sequence_with_unsupported_feature(value, *, ...)

Preflight check raised before the agent runs.

Module Contents

airflow.providers.common.ai.utils.validation.validate_prompt(value, *, decorator_name)[source]

Validate the prompt returned by a decorator’s python_callable.

Accepted (mirrors pydantic-ai’s Agent.run_sync user_prompt):
  • non-empty, non-whitespace str

  • non-empty Sequence (other than str/bytes/bytearray) of pydantic-ai UserContent items; item-level validation is delegated to pydantic-ai at Agent.run_sync time.

Raises TypeError with an actionable message on any other shape.

airflow.providers.common.ai.utils.validation.reject_sequence_with_unsupported_feature(value, *, decorator_name, feature_name, feature_enabled)[source]

Preflight check raised before the agent runs.

Raises TypeError when value is a non-string Sequence and feature_enabled is True. Used to fail fast on combinations (e.g., enable_hitl_review=True + Sequence prompt) that would otherwise fail later – after the LLM call – when the downstream HITL/approval consumer tries to stringify the prompt.

Was this entry helpful?