{ "cells": [ { "cell_type": "markdown", "id": "ee54cde3-7e4d-43f4-b921-e7141ea0f19e", "metadata": {}, "source": [ "# How to add dynamic breakpoints" ] }, { "cell_type": "markdown", "id": "607849c6-4b8c-4e06-ad9c-758bb5a08e86", "metadata": {}, "source": [ "Human-in-the-loop (HIL) interactions are crucial for [agentic systems](https://langchain-ai.github.io/langgraph/concepts/agentic_concepts/#human-in-the-loop). [Breakpoints](https://langchain-ai.github.io/langgraph/concepts/low_level/#breakpoints) are a common HIL interaction pattern, allowing the graph to stop at specific steps and seek human approval before proceeding (e.g., for sensitive actions).\n", "\n", "In LangGraph you can add breakpoints before / after a node is executed. But oftentimes it may be helpful to **dynamically** interrupt the graph from inside a given node based on some condition. When doing so, it may also be helpful to include information about **why** that interrupt was raised.\n", "\n", "This guide shows how you can dynamically interrupt the graph using `NodeInterrupt` -- a special exception that can be raised from inside a node. Let's see it in action!\n", "\n", "## Setup\n", "\n", "First, let's install the required packages" ] }, { "cell_type": "code", "execution_count": 1, "id": "2013d058-c245-498e-ba05-5af99b9b8a1b", "metadata": {}, "outputs": [], "source": [ "%%capture --no-stderr\n", "%pip install -U langgraph" ] }, { "cell_type": "markdown", "id": "d9f9574b", "metadata": {}, "source": [ "
Set up LangSmith for LangGraph development
\n", "\n", " Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started here. \n", "
\n", "