Skip to content
derpx06Notes on systems, models & learning
7. Tools & Agents · lesson 60 of 68 · 1 min · January 10, 2026

Human-in-the-Loop

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

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.

The Agent plans the action. The Human approves it.

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

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).

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.

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).

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).

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."