Lesson 7 of 11
Chapter 18 . LangGraph . Lesson 7 of 11

Human approval gates

interrupt() pauses the graph and waits for a person. Command(resume=...) continues it with their answer.

01Real-world example

Illustration: Before quarantining tests, the pipeline waits for a QA lead to approve, like a manual gate before a production deploy.
Before quarantining tests, the pipeline waits for a QA lead to approve, like a manual gate before a production deploy.

02The graph

Human approval gates as a graph
ask_approval pauses the graph. Command(resume=...) on the same thread_id carries your answer back in.

03How the code does it

  • interrupt(payload) stops the graph inside ask_approval and hands the payload to the caller under "__interrupt__".
  • The checkpointer saves the pause: app.get_state(cfg).next shows ('ask_approval',).
  • app.invoke(Command(resume=answer), cfg) runs ask_approval again; this time interrupt() returns the answer.
  • Resume on the same thread_id, or there is no saved pause to resume.

Key points

  • interrupt() needs a checkpointer
  • Resume with Command(resume=answer)
  • Same thread_id, or it starts over

04Run it

terminal
cd chapter_18_LangGraph/src/chapters
python 007_Human_In_The_Loop.py yes
output
Graph paused. It is asking:
  Quarantine these tests? (yes/no)
   - login_redirect
   - search_autocomplete
Paused before node: ('ask_approval',)

Resumed with 'yes' -> quarantined 2 tests