Skip to content
AI Agent How-To

Home ›Framework how-tos

LangGraph: How to Human in the Loop (Interrupts)

Intermediate ~6 min read Last tested November 2026

Updated 2026-12-01

LangGraph human-in-the-loop pauses graph execution at a chosen node, saves state with a checkpointer, and resumes only when you send Command(resume=...). Call interrupt() inside a node for approvals or typed human input. This guide builds on the checkpointer pattern from LangGraph: add memory and the baseline graph from LangGraph: build an agent. Last tested 2026-12-01.

Prerequisites

  • Python 3.10+
  • A working LangGraph install (pip install langgraph)
  • Familiarity with thread_id from LangGraph: add memory

Docs used:

Steps

1. Install LangGraph with a checkpointer

python -m venv .venv && source .venv/bin/activate
pip install "langgraph>=1.2.12" pydantic

Typed interrupt response schemas require langgraph 1.2.12+ per the interrupts docs.

2. Define a graph node that calls interrupt()

# hitl_graph.py
from typing import Any
from typing_extensions import TypedDict

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import START, StateGraph
from langgraph.types import Command, interrupt

class State(TypedDict):
    user_input: str
    approved: bool | None

def collect_and_approve(state: State) -> dict[str, Any]:
  payload = {"action": "send_email", "preview": state["user_input"]}
  decision = interrupt(payload)  # pauses until resume
  return {"approved": bool(decision)}

builder = StateGraph(State)
builder.add_node("approve", collect_and_approve)
builder.add_edge(START, "approve")
graph = builder.compile(checkpointer=InMemorySaver())

interrupt() must receive JSON-serializable data. The value you pass to Command(resume=...) becomes the return value of interrupt() inside the node.

3. Run until the interrupt surfaces

config = {"configurable": {"thread_id": "email-draft-1"}}
pending = graph.invoke({"user_input": "Thanks for your order!", "approved": None}, config)
print(pending["__interrupt__"])  # default invoke API

Use the same thread_id on every call for this conversation. Reuse it when you resume.

4. Resume with Command(resume=…)

resumed = graph.invoke(Command(resume=True), config=config)
print(resumed["approved"])  # True

Command(resume=...) is the only Command shape intended as input to invoke() / stream() / stream_events() (per LangGraph docs).

5. Optional: typed resume input with response_schema

from pydantic import BaseModel

class Approval(BaseModel):
    approved: bool
    note: str | None = None

def collect_typed(state: State) -> dict[str, Any]:
    answer = interrupt({"question": "Approve sending?"}, response_schema=Approval)
    return {"approved": answer.approved if isinstance(answer, Approval) else answer["approved"]}

Studio and API clients can use response_schema to render a form instead of raw JSON.

6. Stream HITL in a UI loop

For chat UIs, use graph.stream_events(..., version="v3"), read payloads from stream.interrupts, collect the human reply, then call stream_events again with Command(resume=...) until stream.interrupted is false (see interrupts — stream with HITL).

Pair long-running approvals with durable checkpointers (PostgresSaver) from LangGraph: add memory.

Common errors

Resume starts a blank thread. You changed thread_id or dropped config. Log config["configurable"]["thread_id"] before each invoke.

Node code before interrupt() runs twice on resume. LangGraph restarts the node from the top when you resume. Put side effects after interrupt() or make earlier steps idempotent (interrupts docs).

No __interrupt__ key in the result. You called invoke without a checkpointer on compile(). Pass checkpointer=InMemorySaver() (or Postgres) to compile().

Used Command(update=...) as invoke input. That pattern is for returning from nodes, not for continuing after an interrupt. Use Command(resume=...) only.

FAQ

What is LangGraph human in the loop?

A pattern where interrupt() pauses the graph, persists state with a checkpointer, and waits for external input. You continue the same thread with Command(resume=...).

Do I need a checkpointer for interrupts?

Yes. Production graphs should use a durable checkpointer (PostgresSaver, not only InMemorySaver). See persistence overview.

How is this different from tool approval in other frameworks?

LangGraph interrupts are dynamic (any line in any node), not only hooks around tool calls. For MCP tool approval in Claude’s Agent SDK, see Claude Agent SDK: add an MCP server.

Does create_react_agent support interrupts?

Yes when compiled with a checkpointer, but custom nodes with interrupt() are clearer for approval gates. Start from LangGraph: build an agent, then add interrupt nodes or middleware.