You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/oss/add-human-in-the-loop.mdx
-163Lines changed: 0 additions & 163 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1665,169 +1665,6 @@ You can use [LangGraph Studio](/langgraph-platform/langgraph-studio) to debug yo
1665
1665
LangGraph Studio is free with [locally deployed applications](/oss/local-server) using `langgraph dev`.
1666
1666
:::
1667
1667
1668
-
## Debug with interrupts
1669
-
1670
-
To debug and test a graph, use [static interrupts](/oss/human-in-the-loop#key-capabilities) (also known as static breakpoints) to step through the graph execution one node at a time or to pause the graph execution at specific nodes. Static interrupts are triggered at defined points either before or after a node executes. You can set static interrupts by specifying `interrupt_before` and `interrupt_after` at compile time or run time.
1671
-
1672
-
<Warning>
1673
-
Static interrupts are **not** recommended for human-in-the-loop workflows. Use [dynamic interrupts](#pause-using-interrupt) instead.
1674
-
</Warning>
1675
-
1676
-
<Tabs>
1677
-
<Tabtitle="Compile time">
1678
-
1679
-
```python
1680
-
# highlight-next-line
1681
-
graph = graph_builder.compile( # (1)!
1682
-
# highlight-next-line
1683
-
interrupt_before=["node_a"], # (2)!
1684
-
# highlight-next-line
1685
-
interrupt_after=["node_b", "node_c"], # (3)!
1686
-
checkpointer=checkpointer, # (4)!
1687
-
)
1688
-
1689
-
config = {
1690
-
"configurable": {
1691
-
"thread_id": "some_thread"
1692
-
}
1693
-
}
1694
-
1695
-
# Run the graph until the breakpoint
1696
-
graph.invoke(inputs, config=thread_config) # (5)!
1697
-
1698
-
# Resume the graph
1699
-
graph.invoke(None, config=thread_config) # (6)!
1700
-
```
1701
-
1702
-
1. The breakpoints are set during `compile` time.
1703
-
2.`interrupt_before` specifies the nodes where execution should pause before the node is executed.
1704
-
3.`interrupt_after` specifies the nodes where execution should pause after the node is executed.
1705
-
4. A checkpointer is required to enable breakpoints.
1706
-
5. The graph is run until the first breakpoint is hit.
1707
-
6. The graph is resumed by passing in `None` for the input. This will run the graph until the next breakpoint is hit.
1708
-
1709
-
</Tab>
1710
-
<Tabtitle="Run time">
1711
-
1712
-
```python
1713
-
# highlight-next-line
1714
-
graph.invoke( # (1)!
1715
-
inputs,
1716
-
# highlight-next-line
1717
-
interrupt_before=["node_a"], # (2)!
1718
-
# highlight-next-line
1719
-
interrupt_after=["node_b", "node_c"] # (3)!
1720
-
config={
1721
-
"configurable": {"thread_id": "some_thread"}
1722
-
},
1723
-
)
1724
-
1725
-
config = {
1726
-
"configurable": {
1727
-
"thread_id": "some_thread"
1728
-
}
1729
-
}
1730
-
1731
-
# Run the graph until the breakpoint
1732
-
graph.invoke(inputs, config=config) # (4)!
1733
-
1734
-
# Resume the graph
1735
-
graph.invoke(None, config=config) # (5)!
1736
-
```
1737
-
1738
-
1.`graph.invoke` is called with the `interrupt_before` and `interrupt_after` parameters. This is a run-time configuration and can be changed for every invocation.
1739
-
2.`interrupt_before` specifies the nodes where execution should pause before the node is executed.
1740
-
3.`interrupt_after` specifies the nodes where execution should pause after the node is executed.
1741
-
4. The graph is run until the first breakpoint is hit.
1742
-
5. The graph is resumed by passing in `None` for the input. This will run the graph until the next breakpoint is hit.
1743
-
1744
-
<Note>
1745
-
You cannot set static breakpoints at runtime for **sub-graphs**.
1746
-
If you have a sub-graph, you must set the breakpoints at compilation time.
1747
-
</Note>
1748
-
1749
-
</Tab>
1750
-
</Tabs>
1751
-
1752
-
<Accordiontitle="Setting static breakpoints">
1753
-
1754
-
```python
1755
-
from IPython.display import Image, display
1756
-
from typing_extensions import TypedDict
1757
-
1758
-
from langgraph.checkpoint.memory import InMemorySaver
1759
-
from langgraph.graph import StateGraph, START, END
for event in graph.stream(initial_input, thread, stream_mode="values"):
1810
-
print(event)
1811
-
1812
-
# This will run until the breakpoint
1813
-
# You can get the state of the graph at this point
1814
-
print(graph.get_state(config))
1815
-
1816
-
# You can continue the graph execution by passing in `None` for the input
1817
-
for event in graph.stream(None, thread, stream_mode="values"):
1818
-
print(event)
1819
-
```
1820
-
1821
-
</Accordion>
1822
-
1823
-
### Use static interrupts in LangGraph Studio
1824
-
1825
-
You can use [LangGraph Studio](/langgraph-platform/langgraph-studio) to debug your graph. You can set static breakpoints in the UI and then run the graph. You can also use the UI to inspect the graph state at any point in the execution.
1826
-
1827
-

1828
-
1829
-
LangGraph Studio is free with [locally deployed applications](/langgraph-platform/local-server) using `langgraph dev`.
1830
-
1831
1668
## Considerations
1832
1669
1833
1670
When using human-in-the-loop, there are some considerations to keep in mind.
0 commit comments