|
As we have been having conversations with Airflow users, who are using Airflow for Gen AI applications, there are a couple of features that have been brought up as being desirable. As context, based on the most recent Airflow survey, over 8% of Airflow users are now using Airflow for Gen AI use cases.
One of the desired features is to have "human interaction" within the context of the overall orchestration flow. Here are the most common flows:
For a lot of Airflow users, these operations above are expected to be performed through the Airflow UI.
However, Airflow users especially those who use Airflow within the context of other applications may choose to build their own UX mechanisms for these human interactions. For those reasons, an API-driven interaction for the above workflows is also important.
Though the urgency of the requirement for “human in the loop” interactions is driven by Gen AI applications, this need has existed in data pipelines earlier. A common use case within enterprise data pipelines has been for “human validations” to supplement “automated system validations”.
At a high level, we propose to make the following changes:
Existing unchanged DAG / task behavior of relevance:
To be figured out:
HumanOperator(BaseOperator)subject: str - Headline/subject presented to the user for the interaction task - templated fieldbody: str | None = None (longer text possible, CLOB - Markdown) - descriptive text that might give background, hints or can provide background or summary of details that are needed to decide - templated fieldparams: ParamDict | None = None - dictionary of parameter definitions that are in the format of Dag params such that a Form Field can be rendered. Entered data is validated (schema, required fields) like for a Dag run and added to XCom of the task resultoptions: list[str] - List of options that the human can select from and click to complete the task. Buttons on the UI will be presented in the order of the listdefault: str | None = None - The default result (highlighted button) and result that is taken if timout is passed (using existing timeout from BaseOperator)ApprovalOperator(HumanOperator)["Approve", "Reject"].HumanTerminationOperator(HumanOperator)["Stop", "Proceed"].HumanBranchOperator(HumanOperator)multiple: bool = False - If the human can select one or multiple optionsHumanEntryOperator(HumanOperator)
Allows UI forms to be presented so that user can add further information with all options that a TriggerForm allows (same like Dag params). Options and default default to ["OK"] but can be over-ridden.Overview about human tasks as plugin page

If one element is clicked the user is routed to the task where in an additional panel the human interaction is displayed. Here with some example markdown/template filled, a form with two fields to pass numbers and 3 buttons as options

Current users of Airflow, using Airflow for existing use cases, will be unaffected by this change. Users wanting this new feature would need to install the "human" provider package.
Current users who don't use this new feature are unaffected by this change.
As of storing the state and details efficiently one additional DB table is needed to store human task status. This DB table would need to be created by the provider. It assumed to be low volume and impact to the complexity of the database.
The only other AIP which is currently in progress which could be leveraged / impacted (though not necessarily) is AIP-68 Extended Plugin Interface. The plugin interface is needed to add the new panels and screens seamlessly into the UI.
Human failure to respond: