# GRAPH_RECURSION_LIMIT

## Diagnose first

Ask: should this graph terminate in a handful of steps? If yes, you have a cycle. The classic shape is two nodes with edges in both directions and a conditional edge whose condition never flips.

```python
builder.add_edge("a", "b")
builder.add_edge("b", "a")  # where is the exit?
```

## Fix

- Cycle: fix the conditional logic so some path reaches END.
- Legitimately deep: raise the limit per invocation:

```python
graph.invoke({...}, {"recursion_limit": 1000})
```

## Rules

- Do not raise the limit to silence a real infinite loop. A loop that burns 1000 steps burns money and time; fix the logic.
- In JS this is the GRAPH_RECURSION_LIMIT error code on `lc_error_code`.
- Agent loops that call tools forever usually mean the model never gets a usable tool result; check the tool outputs, not just the graph.