Skip to content

Commit 1497152

Browse files
committed
remove dupe
1 parent b0f824c commit 1497152

File tree

1 file changed

+0
-163
lines changed

1 file changed

+0
-163
lines changed

src/oss/add-human-in-the-loop.mdx

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,169 +1665,6 @@ You can use [LangGraph Studio](/langgraph-platform/langgraph-studio) to debug yo
16651665
LangGraph Studio is free with [locally deployed applications](/oss/local-server) using `langgraph dev`.
16661666
:::
16671667

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-
<Tab title="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-
<Tab title="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-
<Accordion title="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
1760-
1761-
1762-
class State(TypedDict):
1763-
input: str
1764-
1765-
1766-
def step_1(state):
1767-
print("---Step 1---")
1768-
pass
1769-
1770-
1771-
def step_2(state):
1772-
print("---Step 2---")
1773-
pass
1774-
1775-
1776-
def step_3(state):
1777-
print("---Step 3---")
1778-
pass
1779-
1780-
1781-
builder = StateGraph(State)
1782-
builder.add_node("step_1", step_1)
1783-
builder.add_node("step_2", step_2)
1784-
builder.add_node("step_3", step_3)
1785-
builder.add_edge(START, "step_1")
1786-
builder.add_edge("step_1", "step_2")
1787-
builder.add_edge("step_2", "step_3")
1788-
builder.add_edge("step_3", END)
1789-
1790-
# Set up a checkpointer
1791-
checkpointer = InMemorySaver() # (1)!
1792-
1793-
graph = builder.compile(
1794-
checkpointer=checkpointer, # (2)!
1795-
interrupt_before=["step_3"] # (3)!
1796-
)
1797-
1798-
# View
1799-
display(Image(graph.get_graph().draw_mermaid_png()))
1800-
1801-
1802-
# Input
1803-
initial_input = {"input": "hello world"}
1804-
1805-
# Thread
1806-
thread = {"configurable": {"thread_id": "1"}}
1807-
1808-
# Run the graph until the first interruption
1809-
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-
![image](/oss/images/static-interrupt.png)
1828-
1829-
LangGraph Studio is free with [locally deployed applications](/langgraph-platform/local-server) using `langgraph dev`.
1830-
18311668
## Considerations
18321669

18331670
When using human-in-the-loop, there are some considerations to keep in mind.

0 commit comments

Comments
 (0)