Human-in-the-Loop Approvals
Add safe checkpoints to autonomous workflows where a human reviews or approves risky actions before the agent proceeds, balancing automation with control.
Human-in-the-Loop Approvals is a free AI Agents with LangChain & Autonomous Workflows lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Agents with LangChain & Autonomous Workflows learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Pause for Humans
Full autonomy is risky for high-stakes actions: sending money, deleting records, emailing customers. A mistake can be costly and irreversible.
Human-in-the-loop (HITL) inserts an approval step so a person confirms before the agent acts.
Where to Add Checkpoints
You do not need approval everywhere — only at sensitive points:
- Before destructive or irreversible operations
- Before external side effects (payments, emails)
- When the agent's confidence is low
Read-only steps can stay fully automatic.
The Interrupt Pattern
In LangGraph you mark nodes where the graph should pause. Execution stops, state is saved, and control returns to your application to await a decision.
graph = builder.compile(
checkpointer=memory,
interrupt_before=['execute_payment']
)Persisting State to Resume
To pause and resume later, the workflow needs a checkpointer that saves state under a thread id. The human might approve minutes or hours later.
config = {'configurable': {'thread_id': 'order-42'}}
result = graph.invoke(initial_state, config)Surfacing the Pending Action
When paused, inspect the saved state to show the human exactly what the agent wants to do — the tool, the arguments, and the reason.
state = graph.get_state(config)
print(state.next)
print(state.values['proposed_action'])Approve and Continue
If the human approves, resume the graph by invoking again with the same thread id. It picks up right where it paused.
graph.invoke(None, config) # resumeReject or Edit
Approval is not the only outcome. A human can reject the action or edit the agent's proposed arguments before continuing — for example fixing a wrong recipient.
graph.update_state(
config,
{'proposed_action': edited_action}
)
graph.invoke(None, config)Asynchronous Approvals
In production the human is not at a console. The pause sends a notification (Slack, email, a dashboard task); the resume happens when they click approve. The thread id ties the request to the right paused run.
Timeouts and Defaults
Decide what happens if no one responds. Options:
- Auto-reject after a timeout (safe default)
- Escalate to another approver
- Hold indefinitely for critical actions
Auditability
Log every approval decision: who approved, when, and what was executed. This audit trail is essential for compliance and for debugging agent behavior later.
Balancing Automation
Too many approvals defeat the purpose of automation; too few add risk. Start cautious, then remove checkpoints as you gain confidence in the agent for specific action types.
Quick Check
Test your HITL knowledge.
Recap
You learned to add human oversight to autonomous workflows:
- Insert approval checkpoints at risky steps only
- Use
interrupt_beforeplus a checkpointer to pause - Surface the proposed action, then approve, reject, or edit
- Handle async approvals, timeouts, and audit logging
Human-in-the-loop makes autonomy safe for high-stakes work.
Frequently asked questions
Is the “Human-in-the-Loop Approvals” lesson free?
Yes — the full text of “Human-in-the-Loop Approvals” is free to read here on the web, and the AI Agents with LangChain & Autonomous Workflows course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Agents with LangChain & Autonomous Workflows course, upgrade to CoddyKit PRO.
What will I learn in “Human-in-the-Loop Approvals”?
Add safe checkpoints to autonomous workflows where a human reviews or approves risky actions before the agent proceeds, balancing automation with control. You practise AI Agents with LangChain & Autonomous Workflows with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AI Agents with LangChain & Autonomous Workflows?
No prior experience is required. AI Agents with LangChain & Autonomous Workflows on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Human-in-the-Loop Approvals” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AI Agents with LangChain & Autonomous Workflows lesson?
Yes. Every AI Agents with LangChain & Autonomous Workflows lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Designing Complex Workflows
- Asynchronous Agent Execution
- Error Handling & Resilience
- Human-in-the-Loop Approvals