In HOTL workflows Humans intervene only when machines need help.
You've probably heard of Human-in-the-Loop, (HITL) workflows, which are common in AI training and automation. But another important pattern is becoming increasingly relevant: Human-on-the-Loop (HOTL) workflows. In this post, we will introduce HOTL and provide an example workflow that implement this pattern.
A Human-on-the-Loop workflow is a fully automated process where humans monitor and supervise its execution and only take action when something requires their attention.
HOTL workflows are common in scenarios like fraud detection, ML model monitoring or DevOps pipelines. Here are the key characteristics of HOTL workflows:
As explained here, in HITL workflows, the automation pauses and waits for human input before continuing. For example to approve a loan before auto-processing. In contrast, in HOTL workflows Humans are not required for the workflow to continue. There is no manual validation steps in the workflow.
To implement this type of workflows, you have to make sure to choose the right workflow orchestration tool when implementing workflows for your organisations, not all tool allow easy interaction with the workflow. For example, in celery, it's not easy to interrupt and change the state of a running workflow. In contrast using more advanced workflow engine like Airflow it could be more easy. In the next section we will present some workflow orchestration tools that simplify the implementation of HOTL workflows.
Airflow is primarily batch-oriented but supports HOTL using sensors, external triggers and manual task reruns or overrides in the UI. This allow the DAG to run in fully automation, alert when needed and allow Human operators handle failure or edge cases.
Temporal is also excellent for HOTL because the workflows are code based and Humans can send signals to workflows without pausing them. So, automated workflow continues unless a human operator sends a signal to block or override a transaction.
Prefect is naturally HOTL friendly because Prefect offers Automations and Notifications when conditions are met and Humans can intervene via the UI (retries, pause, resume).
Let's take a real-world example: Automatically detect fraud in transactions but allow a human analyst to intervene only when the system flags something suspicious. We will used Prefect in this example. If you are new to prefect you can check this link to learn how to create prefect workflows. Here is an overview of the workflow:
1from prefect import flow, task, get_run_logger2import random3import httpx4import os56# Simulated model that scores fraud risk7@task8def score_transaction(transaction):9 probability = random.random()10 return {"transaction": transaction, "fraud_score": probability}111213@task14def process_transaction(data):15 logger = get_run_logger()16 logger.info(f"Auto-approved transaction: {data['transaction']}")17 return "approved"1819@task20def notify_human(data):21 logger = get_run_logger()22 logger.warning(23 f"Suspicious transaction detected! Score: {data['fraud_score']}"24 )25 webhook = os.environ.get("SLACK_WEBHOOK_URL")26 if webhook:27 httpx.post(webhook, json={"text": f"Suspicious transaction: {data}"})28 return "awaiting-human-review"2930# Save transaction to data store31@task32def save_transaction(data):33 logger = get_run_logger()34 logger.info(f"Transaction data saved: {data}")35 return "saved"3637@flow38def fraud_detection_flow(transaction: dict):39result = score_transaction(transaction)40if result["fraud_score"] < 0.3:41 return process_transaction(result)42else:43 process_transaction(result)44 return notify_human(result)4546save_transaction(result)4748# The Analyst reviews alerts asynchronously; the workflow continues processing other transactions.4950if __name__ == "__main__":51 fraud_detection_flow({"id": 123, "amount": 350})52
This workflow is a HOTL because the flow does not stop and wait for a human, the analysts review alerts asynchronously and the automation continues running all other transactions.
Human-on-the-Loop workflows differ from HITL in one crucial way, HITL requires humans. HOTL only involves humans when needed. With modern orchestration tools like Prefect, Airflow or Temporal, you can easily implement HOTL workflows.