
Failure-Safe Exits
How to crash gracefully.
Failure-Safe Exits
Not all paths lead to success.
The Global Timeout
If your graph gets stuck in an infinite internal loop, the Recursion Limit hits.
# Set a hard limit on steps
try:
graph.invoke(inputs, {"recursion_limit": 50})
except GraphRecursionError:
return "I'm sorry, I got stuck in a loop. Please try again."
The "I Don't Know" Node
Train your agent to route to an explicit DunnoNode if it is confused.
It is far better for the bot to say "I don't know" (and end the graph) than to hallucinate a fake answer.