Skip to main content

Overview

Human-in-the-Loop (HITL) patterns let you pause execution for human review, approval, or input. This is essential for:
  • Content Moderation - Review AI-generated content before publishing
  • 🎯 Decision Approval - Require human sign-off on critical actions
  • ✏️ Content Editing - Let humans refine AI outputs
  • 🔍 Quality Control - Inspect intermediate results

The Interrupt Primitive

The interrupt() function pauses execution and returns control to the caller:

How Interrupts Work

  1. Node calls interrupt() - Execution pauses
  2. Graph returns with __interrupt__ key - Contains interrupt data
  3. Application shows data to human - Display UI, wait for input
  4. Resume with Command(resume=…) - Continue execution with human response

Basic Interrupt Example

Interrupts require checkpointers because execution state must be persisted between the interrupt and resume calls.

Interrupt Patterns

Pattern 1: Approve/Reject

Simple binary approval workflow:

Pattern 2: Edit Content

Allow humans to modify AI-generated content:

Pattern 3: Iterative Refinement

Loop until human approves:

Interrupt Configuration

Configure where interrupts can happen using compile options:

Best Practices

1. Provide Clear Context

Give users all the information they need to make decisions:

2. Handle Resume Values Safely

Always validate and provide defaults for resume values:

3. Keep Interrupts Deterministic

Avoid conditional interrupts - keep the order consistent:

Next Steps