LangGraph 1 cheatsheet

LangGraph 1: Human in the loop

2 common LangGraph 1 tasks.

Pause for human input

Call interrupt inside a node. The graph stops, saves its state and returns the value you passed. Needs a checkpointer.

from langgraph.types import interrupt

def approval(state: State):
    answer = interrupt("Approve this action?")
    return {"approved": answer}

Resume after an interrupt

Resume the same thread with a value, which becomes the return value of interrupt().

from langgraph.types import Command

graph.invoke(Command(resume=True), config)

Was this page helpful?