|
|
ADK Human-in-the-Loop
Author: Venkata Sudhakar
Human-in-the-Loop (HITL) is a pattern where an ADK agent pauses execution and waits for a human to review, approve, or provide input before continuing. This is essential in high-stakes workflows such as refund approvals, large purchase orders, or account escalations at ShopMax India. ADK implements HITL using a custom tool that raises a signal, combined with session state to resume the agent after human input is received. The agent stores its pending decision in session state, then the application layer presents the request to a human operator. The below example shows an ADK agent that pauses for manager approval before issuing a refund above Rs 5,000.
It gives the following output,
Agent initialized: refund_agent
Model: gemini-2.0-flash
Tools registered: request_approval, process_refund
The below example shows the full interaction - the agent pauses, the operator approves, and the agent resumes to complete the refund.
It gives the following output,
Step 1: Processing refund request...
Agent: I have flagged this refund of Rs 8,500 for manager approval as it exceeds the Rs 5,000 threshold. Request sent to manager for review.
Step 2: Manager approved the refund.
Agent: Refund of Rs 8500 processed for order ORD-8821. The customer will receive the amount within 3-5 business days.
ShopMax India uses the HITL pattern for high-value refunds, bulk order cancellations, and price override requests. Agents handle routine cases automatically while escalating edge cases to the right human at the right time - reducing fraud risk and keeping managers focused on decisions that need human judgement.
|
|