Blog Post

Azure AI Foundry Blog
4 MIN READ

Multi-agent Workflow with Human Approval using Agent Framework

MaheshMSFT's avatar
MaheshMSFT
Icon for Microsoft rankMicrosoft
Oct 31, 2025

The solution scripts from this article demonstrate an effective approach to orchestrate Microsoft Agent Framework-powered sequential workflow involving persistent Azure AI Foundry agents, integrating human approval for critical actions.

In modern AI-driven workflows, balancing automation with human oversight is critical, especially for high-stakes decisions. The solution scripts from this article demonstrate an effective approach to orchestrate Agent Framework-powered sequential workflow involving persistent Azure AI Foundry agents, integrating human approval for critical actions. By leveraging workflow checkpointing, the system ensures state persistence, allowing workflows to pause for human decisions and seamlessly resume from the last checkpoint once approval is granted.

This article explores the implementation details of the script, including its agent setup, human approval simulation and state management, providing a robust framework for building AI workflows with human-in-the-loop control.

Scenario


In this workflow example, three specialised agents collaborate sequentially to manage industrial sensor data with human-in-the-loop control.
The Data Analyser Agent initiates the process by collecting pipeline sensor readings (pressure, temperature, flow rate), detecting anomalies and summarising findings in a structured format. These results are passed to the Risk Assessor Agent V2, which evaluates severity based on predefined thresholds and determines appropriate actions - such as scheduling maintenance or initiating an immediate shutdown.

For high-impact decisions, the workflow pauses at a checkpoint, saving its state and requesting human approval before proceeding. 
Once approval is received, the Maintenance Scheduler Agent resumes the process, assigning tasks to relevant teams and confirming execution steps. This design ensures automation efficiency while maintaining critical human oversight for safety and compliance.

The workflow pauses when human approval is required and triggers an entry in a simulated external system for decision capture. Once the external system records an approve or reject decision, the workflow resumes, verifies the approval status in that system and then executes critical actions such as scheduling maintenance or shutting down equipment.

Code Overview

Setting up Azure Resources and Local Environment

Set up the Azure AI Foundry resource along with a large language model. Retrieve the endpoint details for the Azure AI Foundry Project and the name of the deployed model, then update the relevant variables in your environment file accordingly.

AZURE_AI_PROJECT_ENDPOINT = "<AZURE AI FOUNDRY PROJECT ENDPOINT>"
AZURE_AI_MODEL_DEPLOYMENT_NAME = "<gpt-4o>"

Proceed with the installation of the requirements.txt file.

Creating Persistent Agents

Azure AI Foundry persistent agents used in the workflow are created using AIProjectClient class from Azure AI Foundry SDK. It is implicitly installed as part of Agent Framework SDK (Python) as listed in requirements.txt file. Once agents are created, they can be viewed in the Azure AI Foundry portal under Agents blade.


You may observe that the tools are not yet associated with any agents. This association will be created during the process of creating agent instances for workflows. Creating agents in AI Foundry allows you to utilise and share them across multiple workflows and ensures they are accessible in a centralised location.

After agents are created, each is assigned an ID that can be accessed through the agent's `id` property or found in the Azure AI Foundry portal. These IDs will be required in next script to use the agents as part of Agent Framework orchestrated workflow.

Other important point to note is that Maintenance Scheduler Agent (v2) has special instructions that [Schedule Maintenance] and [Immediate Shutdown] actions require human approval result [APPROVED]. This agent can retrieve approval status when required as per Risk Assessor Agent (v2) and Maintenance Scheduler Agent (v2) adds [PENDING] keyword in messages if approval is required but not yet granted.

Reference Script: A03_Create_Multiple_Foundry_Agent_Persistent.py

Creating Sequential Workflow

Necessary agents for the workflow are setup using ChatAgent class from Agent Framework, this will invoke the Azure AI Foundry agents created earlier.

The local agent tools are attached to the ChatAgent instance. There are number of tools made available to the agents which simulate actions to support the workflow demonstration.

Agent Tools

  • get_data: Get the data (temperature, pressure, flow rate) for a given pump in JSON format.
  • schedule_maintenance: Scheduling maintenance for the given equipment, returns maintenance request number.
  • send_shutdown_equipment_notification: Send notification for shutting down the given equipment and notifying relevant teams, returns notification ID.
  • send_approval_rejection_notification: Send notification that the requested action was rejected by human approver.
  • request_human_approval: equest human approval for critical actions via external system.
  • get_human_approval_status: Check the human approval status from the external JSON file when the workflow is resumed.

Section of the code below builds initiates in memory checkpoint storage and builds a sequential workflow. Checkpoints is a feature of Agent Framework which allows you to save the state of a workflow at specific points during its execution and resume from those points later. This example utilises this feature for enabling a long-running workflow where you want to pause and resume execution at a later time.

The following code starts a new workflow if no checkpoint file exists or resumes from the last checkpoint if the file is found.  When implementing this, you can assign a unique suffix such as the workflow ID to the checkpoint file to make sure the correct checkpoint is created and identified when resuming the workflow.

The code below checks if human approval was requested by checking keyword [PENDING] in the chat messages, as mentioned above. The presence of this keyword is a deciding factor in checkpoint requires saving or it does not.

The simulation of creating an entry into an external approval system is achieved by approval_db.json file (This can be an API call to relevant system / database). This file gets generated with status [PENDING] when human approval is required. The Maintenance Scheduler Agent (v2) will not action the tasks when workflow is re-run unless the approval is provided by manually updating the status to [APPROVED] in this file. The workflow when re-run, will resume from required step instead of starting from very first step when approval is PENDING / APPROVED / REJECTED.


Reference Script: W04_Sequential_Workflow_Human_Approval.py

GitHub: View code sample

Updated Oct 31, 2025
Version 1.0
No CommentsBe the first to comment