airflow.providers.common.ai.utils.hitl_review¶
Shared data models, exceptions, and XCom key constants for HITL Review.
Used by both the API-server-side plugin (plugins.hitl_review) and the
worker-side operator mixin (mixins.hitl_review). Depends only on
pydantic and the standard library.
Storage: all session state is persisted as XCom entries on the running task instance. See the XCom key constants below for the key naming scheme.
Attributes¶
These xcom keys are reserved for agentic operator with HITL feedback loop. |
|
Session metadata written by the worker. |
|
Human action command written by the plugin. |
|
Per-iteration AI output (append-only, written by worker). |
|
Per-iteration human feedback (append-only, written by the plugin, and by the worker when it resumes). |
|
Classes¶
Lifecycle states of a HITL review session. |
|
Single turn in the feedback conversation. |
|
Session metadata stored in the |
|
Human action payload stored in the |
|
Payload for the |
|
API response for a HITL review session (combined from multiple XCom entries). |
Functions¶
|
Wrap an agent output or human feedback for its per-iteration XCom. |
|
Return the text |
Module Contents¶
- airflow.providers.common.ai.utils.hitl_review.HumanActionType[source]¶
These xcom keys are reserved for agentic operator with HITL feedback loop.
- airflow.providers.common.ai.utils.hitl_review.XCOM_AGENT_SESSION = 'airflow_hitl_review_agent_session'[source]¶
Session metadata written by the worker.
Value:
{"status": "...", "iteration": N, "max_iterations": M, "prompt": "...", "current_output": "..."}.
- airflow.providers.common.ai.utils.hitl_review.XCOM_HUMAN_ACTION = 'airflow_hitl_review_human_action'[source]¶
Human action command written by the plugin.
Value:
{"action": "approve"|"reject"|"changes_requested", "feedback": "...", "iteration": N}.
- airflow.providers.common.ai.utils.hitl_review.XCOM_AGENT_OUTPUT_PREFIX = 'airflow_hitl_review_agent_output_'[source]¶
Per-iteration AI output (append-only, written by worker).
Actual key:
airflow_hitl_review_agent_output_1,_2, … Value:{"text": "...", "dag_id": "..."}(seewrap_review_text()).
- airflow.providers.common.ai.utils.hitl_review.XCOM_HUMAN_FEEDBACK_PREFIX = 'airflow_hitl_review_human_feedback_'[source]¶
Per-iteration human feedback (append-only, written by the plugin, and by the worker when it resumes).
Actual key:
airflow_hitl_review_human_feedback_1,_2, … Value:{"text": "...", "dag_id": "..."}(seewrap_review_text()).
- airflow.providers.common.ai.utils.hitl_review.HITL_OPTION_REQUEST_CHANGES = 'Request changes'[source]¶
- airflow.providers.common.ai.utils.hitl_review.wrap_review_text(text, *, dag_id)[source]¶
Wrap an agent output or human feedback for its per-iteration XCom.
The plugin reads these XComs through the XCom backend, which may open a string that looks like a reference to its storage (
XComObjectStorageBackenddoes), and the text comes from the model or the reviewer. Wrapped, the text is never such a string, and naming the Dag keeps the plugin from showing another Dag’s entry that a stored reference resolves to.
- airflow.providers.common.ai.utils.hitl_review.unwrap_review_text(value, *, dag_id)[source]¶
Return the text
wrap_review_text()wrapped fordag_id, orNonefor any other value.
- class airflow.providers.common.ai.utils.hitl_review.SessionStatus[source]¶
-
Lifecycle states of a HITL review session.
- class airflow.providers.common.ai.utils.hitl_review.ConversationEntry(/, **data)[source]¶
Bases:
pydantic.BaseModelSingle turn in the feedback conversation.
- timestamp: datetime.datetime[source]¶
- class airflow.providers.common.ai.utils.hitl_review.AgentSessionData(/, **data)[source]¶
Bases:
pydantic.BaseModelSession metadata stored in the
airflow_hitl_review_agent_sessionXCom.Written by the worker only.
- status: SessionStatus[source]¶
- class airflow.providers.common.ai.utils.hitl_review.HumanActionData(/, **data)[source]¶
Bases:
pydantic.BaseModelHuman action payload stored in the
airflow_hitl_review_human_actionXCom.Written by the plugin only. Invalid
actionvalues (e.g. typos like “approved”) fail validation at parse time instead of causing the worker to loop indefinitely.- action: HumanActionType[source]¶
- class airflow.providers.common.ai.utils.hitl_review.HumanFeedbackRequest(/, **data)[source]¶
Bases:
pydantic.BaseModelPayload for the
POST .../feedbackendpoint.
- class airflow.providers.common.ai.utils.hitl_review.HITLReviewResponse(/, **data)[source]¶
Bases:
pydantic.BaseModelAPI response for a HITL review session (combined from multiple XCom entries).
- status: SessionStatus[source]¶
- conversation: list[ConversationEntry] = [][source]¶