Skip to Content

Human-in-the-Loop (HITL) Interrupts

When to use

Pause the agent before a sensitive action (refund, deletion, financial move) and require human approval.

Analogy

A junior doctor needs attending sign-off before prescribing anything risky. The junior drafts, the attending reviews, then the system acts.

Data-flow diagram

   user_q -> draft_action -> [PAUSE for review]
                                     |
                            approve?  yes / no
                            |              |
                       execute        abort

Deep explanation

HITL flows gate dangerous steps behind human approval. LangGraph’s interrupt_before / interrupt_after pause execution; the application presents the proposed action to the user; an update_state call resumes (or aborts). Always use HITL for actions that have side-effects in production.

Examples

Example 1

app = graph.compile(interrupt_before=['execute'])
state_history = []
for step in app.stream({'messages': [user_input]}, config=config):
    state_history.append(step)
    if step.get('next') == ('execute',):
        print('awaiting approval; current draft:', step['__start__'] or step)

interrupt_before=[‘execute’] pauses execution right before a sensitive node.

Example 2

# resume after approval
from langgraph.checkpoint.sqlite import SqliteSaver
app.update_state(config, {'approved': True})
for step in app.stream(None, config=config):
    print(step)

update_state injects the human’s decision (approve or reject) into the state dict.

Example 3

# abort after rejection
app.update_state(config, {'approved': False})
# walk to the END node manually or short-circuit

stream(None) resumes from the saved checkpoint — the agent re-runs from the interrupted node.

Common mistake

Running financial actions without HITL. The agent decides and the system acts — no approval. Always gate production-write actions.

Key takeaway

interrupt_before sensitive nodes; present state to reviewer; update_state with approved flag; resume with stream(None). Test the abort path explicitly.

Production Failure Playbook

Failure scenario 1: no-abort-path

Failure scenario 2: approval-bind-jumping