Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 8 · 7. Tools & Agents
Lesson 60 of 68

Human-in-the-Loop

The ultimate safety layer. Correction, Approval, and Escalation.

Derpx0610 Jan · 1 min read
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. The Myth of Autonomy2. Patterns of CollaborationA. Approval (The Gate)B. Correction (The Teacher)C. Escalation (The Bailout)3. Implementing in LangGraph4. Common Failure Modes in Agent Systems5. Final Thoughts: Agents are Systems
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. The Myth of Autonomy2. Patterns of CollaborationA. Approval (The Gate)B. Correction (The Teacher)C. Escalation (The Bailout)3. Implementing in LangGraph4. Common Failure Modes in Agent Systems5. Final Thoughts: Agents are Systems

1. The Myth of Autonomy

We want "Autonomous Agents." We dream of agents that run forever. But in production, full autonomy is terrifying. Do you want an AI to send emails to your CEO without checking? Do you want an AI to delete production databases?

Human-in-the-Loop is not a failure of AI. It is a feature of reliable software.

2. Patterns of Collaboration

A. Approval (The Gate)

The Agent plans the action. The Human approves it.

  • Agent: "I want to refund User X $50."
  • Human (Click): "Approve."
  • Agent: Executes refund.

B. Correction (The Teacher)

The Agent plans the action. The Human edits it.

  • Agent: "Draft email: 'Hi dude, here is your refund.'"
  • Human (Edit): Change "dude" to "Customer."
  • Agent: Sends corrected email.
  • Bonus: The Agent learns from this edit for next time (Few-Shot Prompting update).

C. Escalation (The Bailout)

The Agent gets stuck. It calls the human.

  • Agent: "I have tried 3 times to find the invoice but failed. Need human help."
  • Human: Takes over the chat.

3. Implementing in LangGraph

LangGraph makes HITL trivial using breakpoints.

Python
workflow = Graph()
# ... define nodes ...

# Interrupt before executing 'action_node'
workflow.compile(interrupt_before=["action_node"])

When the graph hits action_node, it freezes. The state is saved. The UI shows a button "Approve/Reject." When the user clicks, you call graph.invoke(..., resume=True).

4. Common Failure Modes in Agent Systems

Even with HITL, things break.

  1. Tool Overuse: Agent uses a Calculator to add 1+1. (Wasted latency).
  2. Hallucinated Actions: Agent says "I have sent the email" but never called the tool. (State Desynchronization).
  3. Runaway Loops: Agent gets stuck in a "Sorry -> Retry -> Sorry" loop burning $10/minute. (Need Loop Limits).

5. Final Thoughts: Agents are Systems

Agents don't emerge from clever prompts. They emerge from explicit interfaces, robust state management, and failure-aware design. Treat them like junior employees: Give them clear tools, check their work, and help them when they fail.

Key Intuition: "The best agent is a teammate, not a black box."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonLangGraph: Stateful AgentsNext lesson →Async & High-Throughput Patterns