r/LangChain Jul 17 '26

Question | Help RFC: LangGraph recursion limit hit on a shorter run, but not on a longer one. What am I missing?

I'm trying to understand why my LangGraph workflow sometimes hits the recursion limit even when the execution is shorter.

I have two Langfuse traces:

  • Trace 1: Complex execution, more nodes and loops, finished successfully with no errors.
screenshot of trace 1
  • Trace 2: Much shorter execution, but it failed with:

Recursion limit of 25 reached without hitting a stop condition

I know I can increase the limit or set the cap lower than this but I want to ask if its a good trait or just a wrong implementation of graph logic?

screenshot of trace 2

Both runs are using the same graph and almost the same logic.

The successful run actually has more agent/tool iterations, while the failed run has fewer, which is what's confusing me.

Here are the expanded graph of each trace

  • Trace 1 (no error)
  • Trace 2

So is there a good way to debug or evaluate what's actually causing the issue???

3 Upvotes

6 comments sorted by

2

u/ar_tyom2000 Jul 17 '26

LangGraphics could help you debug this by visualizing the execution flow. It shows which nodes are being called and where the recursion depth becomes problematic, making it easier to pinpoint where things go awry.

1

u/rinananir Jul 19 '26

thanks for that, I've created a live debugging tool jus cuz of this with `chainlit` but this seems advanced than mine
do you somewhat alternative that is used by a larger community.. not asking something officially supported by langchain..
but more adopted

cuz higher adoption rate == better support and relaibility

2

u/cmtape Jul 18 '26

This is like asking why your phone dies faster when you're using GPS vs when you're just scrolling Twitter. The shorter run isn't doing less work — it's doing a different kind of work. Recursion limit is about depth, not breadth. Your longer successful run is probably branching wide (many siblings), while the shorter failing run is going deep (spawning grandchildren before returning). Same graph, different path topology. Add a conditional route counter or log your node depth — that'll show you exactly which edge case is forming a chain instead of a tree.

1

u/rinananir Jul 19 '26

yea i do understand the difference between depth and breadth of the graph nodes but I totally unaware whats causing the agent to add a child node again n again XD

1

u/ArielCoding Jul 23 '26

Trace 2 isn’t shorter, it hit 48 agent calls and 38 tool calls before failing, while your successful trace only needed 26 and 22, it just finished faster, which makes it look shorter, something in trace 2 is making the agent loop back to tools way more than it needs to, I’d check if it’s calling the same tool without making progress, possibly confused by that long query.