Skip to content
Hameed's dev blog

Blog

Agentic AI Chapter 8: Human-in-the-Loop, Persistence and Approval Workflows

·3 min read·---
Agentic ai chapter 8 human in the loop and persistence.png
On this page

Part of the Agentic AI study series.

Some actions are too risky or need human judgment. In those cases the agent pauses and asks a human, either the user or an internal team, for approval, clarification, or more information.

Agentic AI Chapter 8: Human-in-the-Loop, Persistence and Approval-Based Workflows, handwritten study notes

📊 Real-World Example: A Return That Needs Approval

The user asks to return a laptop from order #408-12345 and get a refund.

The LLM plans: get order details, check return policy, create the return, and if the refund amount is above ₹10,000, require approval. Then confirm with the user.

  • Refund of ₹10,000 or less: the agent proceeds automatically, creates the return, processes the refund, and confirms.
  • Refund above ₹10,000: the agent requests human approval from a support agent or manager. If approved, it creates the return and processes the refund. If rejected, it explains to the user why the return cannot be processed.

🔴 CHECKPOINT: Remember

When to use a human in the loop: financial impact (refund above ₹10,000), account changes (delivery address to a new country), fraud or security risk, ambiguous intent, policy exceptions (return after 60 days), data deletion, and other high-risk actions.

Types of involvement: user confirmation, asking for additional information, internal human review, an approval workflow, and manual override.

State transitions: Start, Checking Eligibility, Awaiting Approval, then Approved and Return Completed, or Rejected.

Persistence. Save the current step and status, the order, return, and refund details, a conversation summary, the approval status, and timestamps with audit logs. Store it in a database, a cache such as Redis for session state, a conversation store with checkpoints, and audit logs for compliance. When the human approves, the agent updates the state, resumes from the next step, completes the return, and notifies the user.

Best practices: use approval for high-risk cases, persist state after every step, design clear approval and escalation workflows, handle timeouts, keep users informed, and maintain audit logs.

Human-in-the-loop improves safety, trust, and handling of edge cases. It is essential for real-world enterprise and e-commerce systems.

🛠️ From My Own Work

In this blog repo the assistant can edit files, but I make every commit myself. That is a human approval gate on the one irreversible step, and the work is saved in the working tree until I review it.


← Previous: Planning, Routing and Decisions · Back to the series start

Practical notes on product management, distributed systems, and AI—written from real engineering and product experience.