Preview — full styling will appear after the next deploy completes.

agentic-ai-patterns

Human-in-the-Loop

Interrupt for human approval

The graph pauses mid-execution and surfaces the agent's proposed action to a human. Execution only continues after the human approves, modifies, or rejects the action.

flowchart TD
    S([__start__]) --> G[generate_sql]
    G --> V[human_review]
    V -->|interrupt| H{{"👤 Human Review"}}
    H -->|approve / modify| X[execute_sql]
    X --> F[format_answer]
    F --> E([__end__])

Human-in-the-Loop (HitL) enables safe deployment of agentic systems by requiring a human to review the agent's proposed next action before any irreversible operation occurs. The `interrupt()` function pauses graph execution and returns the proposed action to the caller — no tool is run, no data is written.

LangGraph's `MemorySaver` checkpointer persists the full graph state while waiting for human input. When the human responds, the caller resumes execution with `Command(resume={"approved": True})` and a thread ID that identifies which paused run to continue.

This pattern is essential for any agent that writes to databases, sends emails, deploys infrastructure, or takes actions with real-world consequences. The cost of the added latency is far outweighed by the ability to catch and correct errors before they propagate.