Breakpoints¶
Breakpoints pause graph execution at defined points and let you step through each stage. They use LangGraph's persistence layer, which saves the graph state after each step.
With breakpoints, you can inspect the graph's state and node inputs at any point. Execution pauses indefinitely until you resume, as the checkpointer preserves the state.
Set breakpoints¶
graph = graph_builder.compile( # (1)!
interrupt_before=["node_a"], # (2)!
interrupt_after=["node_b", "node_c"], # (3)!
)
- The breakpoints are set during
compile
time. interrupt_before
specifies the nodes where execution should pause before the node is executed.interrupt_after
specifies the nodes where execution should pause after the node is executed.
await client.runs.wait( # (1)!
thread_id,
assistant_id,
inputs=inputs,
interrupt_before=["node_a"], # (2)!
interrupt_after=["node_b", "node_c"] # (3)!
)
client.runs.wait
is called with theinterrupt_before
andinterrupt_after
parameters. This is a run-time configuration and can be changed for every invocation.interrupt_before
specifies the nodes where execution should pause before the node is executed.interrupt_after
specifies the nodes where execution should pause after the node is executed.
await client.runs.wait( // (1)!
threadID,
assistantID,
{
input: input,
interruptBefore: ["node_a"], // (2)!
interruptAfter: ["node_b", "node_c"] // (3)!
}
)
client.runs.wait
is called with theinterruptBefore
andinterruptAfter
parameters. This is a run-time configuration and can be changed for every invocation.interruptBefore
specifies the nodes where execution should pause before the node is executed.interruptAfter
specifies the nodes where execution should pause after the node is executed.
Tip
This example shows how to add static breakpoints. See this guide for more options for how to add breakpoints.
from langgraph_sdk import get_client
client = get_client(url=<DEPLOYMENT_URL>)
# Using the graph deployed with the name "agent"
assistant_id = "agent"
# create a thread
thread = await client.threads.create()
thread_id = thread["thread_id"]
# Run the graph until the breakpoint
result = await client.runs.wait(
thread_id,
assistant_id,
input=inputs # (1)!
)
# Resume the graph
await client.runs.wait(
thread_id,
assistant_id,
input=None # (2)!
)
- The graph is run until the first breakpoint is hit.
- The graph is resumed by passing in
None
for the input. This will run the graph until the next breakpoint is hit.
import { Client } from "@langchain/langgraph-sdk";
const client = new Client({ apiUrl: <DEPLOYMENT_URL> });
// Using the graph deployed with the name "agent"
const assistantID = "agent";
// create a thread
const thread = await client.threads.create();
const threadID = thread["thread_id"];
// Run the graph until the breakpoint
const result = await client.runs.wait(
threadID,
assistantID,
{ input: input } // (1)!
);
// Resume the graph
await client.runs.wait(
threadID,
assistantID,
{ input: null } // (2)!
);
- The graph is run until the first breakpoint is hit.
- The graph is resumed by passing in
null
for the input. This will run the graph until the next breakpoint is hit.
Create a thread:
curl --request POST \
--url <DEPLOYMENT_URL>/threads \
--header 'Content-Type: application/json' \
--data '{}'
Run the graph until the breakpoint:
curl --request POST \
--url <DEPLOYMENT_URL>/threads/<THREAD_ID>/runs/wait \
--header 'Content-Type: application/json' \
--data "{
\"assistant_id\": \"agent\",
\"input\": <INPUT>
}"
Resume the graph:
Learn more¶
- LangGraph breakpoints guide: learn more about adding breakpoints in LangGraph.