A beginner-friendly tutorial demonstrating how to build AI workflows with human oversight using LangGraph.
This notebook teaches you how to build an automated document compliance checker that reviews files for policy violations while keeping humans in the decision-making loop. You'll learn core LangGraph concepts through a practical, real-world example inspired by policy compliance work in government and enterprise organizations.
An AI agent that:
- Scans documents for policy compliance violations
- Pauses execution when it finds potential issues
- Asks for human confirmation before continuing
- Resumes processing based on your decisions
You'll build this in two stages:
- Pattern matching version - Fast, free, deterministic (no API key needed)
- LLM-enhanced version - Smarter analysis using Claude (requires Anthropic API key)
Even smart AI systems need human oversight, especially for:
- Compliance and policy enforcement
- Ambiguous cases requiring context or judgment
- Situations where mistakes have real consequences
- Building trust in automated systems
This tutorial shows you how to build workflows where AI handles the tedious scanning work while humans make the final decisions.
- LangGraph fundamentals: State management, nodes, edges, and checkpointers
- Human-in-the-loop patterns: Using
interrupt()andCommand(resume=...)to pause and resume workflows - Iterative development: Starting simple, then adding sophistication
- Trade-offs: When to use pattern matching vs. LLM analysis
- Real-world application: Why human oversight matters even with advanced AI
- Basic Python knowledge
- Familiarity with Jupyter notebooks
- A conda environment (recommended) or pip
Optional: Anthropic API key for Part 2 (LLM-enhanced version)
- Get one at https://console.anthropic.com
conda create -n langgraph-tutorial python=3.13
conda activate langgraph-tutorial
conda install -c conda-forge langgraph langchain-anthropic -y- Clone or download this repository
- Open
policy_compliance_checker.ipynbin Jupyter - Run the cells in order
- Part 1 requires no API key - start here to learn the basics!
- When ready for Part 2, add your Anthropic API key
This pattern works for many scenarios beyond document compliance:
- Legal/Compliance: Reviewing contracts, policies, or regulatory documents
- Content Moderation: Flagging content that needs expert review
- Quality Assurance: Checking code, documentation, or data quality
- Medical/Healthcare: Identifying cases requiring specialist attention
- Financial: Reviewing transactions or documents for approval
policy_compliance_checker.ipynb- Main tutorial notebookREADME.md- This filesample_documents/- Example files that are created automatically when you run the notebook
Ideas for building on this tutorial:
- Add support for .docx, .pdf, or other file formats
- Implement batch processing for directories
- Generate compliance reports (PDF/HTML)
- Use persistent storage (databases) for checkpoints
- Add multi-user support with role-based review
- Create custom policy templates
- Integrate with document management systems or Slack
- Built with LangGraph
- Tutorial developed for the Anaconda community