Module 14 Lesson 1: Agent Approval Flows
Safe Autonomy. How to implement 'Pause and Approve' patterns to ensure humans sign off on high-stakes AI actions.
Human-in-the-Loop: Approval Flows
In enterprise AI, some actions are "Irreversible."
- Sending a $10,000 refund.
- Deleting a production database.
- Sending an email to 1 million users.
For these, you cannot give the AI 100% autonomy. You need Human-in-the-Loop (HITL).
1. How HITL Works with Agents
The Agent identifies a "High-risk" tool and Pauses its execution. It returns a "Pending" status to the UI.
- Agent: "I want to send this refund. Please approve."
- Human: (Clicks 'Approve' in Dashboard).
- Agent: (Resumes execution and calls the tool).
2. Implementing the "Pause"
In your Lambda function (Action Group), if certain criteria are met, instead of executing the tool, you return a message:
if amount > 1000:
return {
"status": "AWAITING_APPROVAL",
"message": "Refund exceeds threshold. Waiting for human."
}
3. Visualizing the Approval Loop
graph TD
A[Agent: I want to refund $5k] --> C{Amount > $1k?}
C -->|Yes| P[Pause: State Saved]
P --> U[UI: Admin Approval Required]
U -->|Human: Approved| R[Resume: Call Tool]
R --> Final[Goal Met]
💡 Guidance for Learners
HITL is the "Seatbelt" of the AI world. It allows you to build powerful agents with Confidence. You don't have to worry about a "Billion Token Hallucination" because a human is the final gatekeeper for the most expensive actions.
Summary
- HITL is mandatory for high-risk autonomous actions.
- The agent identifies the risk and pauses the flow.
- Status messages communicate the need for approval to the frontend.
- Approval acts as the "resume" signal for the agent brain.