[PR #5158] feat: post hook - create_react_agent support identical tool call ids #4271

Closed
opened 2026-02-20 17:49:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5158

State: closed
Merged: No


@sydney-runkle
This fixes #5157.

While working on the fix/tests I have observed that FakeToolCallingModel had no way to "stop producing tool calls" which was working only because the bug existed. (Think about it this way, it would keep producing the same tool call id - over and over, and the router would always assume the tool call is completed, and thus would end the execution).

but I needed to reproduce the above case, without hitting the max graph recursion limit - so I added an optional arg to allow max generations with tool calls.

After fixing the bug, I observed the test test_post_model_hook_with_structured_output fails on max graph recursion due to the above reason, so I took the liberty of fixing that test, resetting the agent/model state such that the two tested modes (invoke vs stream) are independent. I suggest splitting them to two tests though.

As an aside - I do wonder - why even test for tool call completions in the post_model_hook router?
And why does the logic assumed tools->post_model_hook is a possible path?

This probably complicated the logic and is not expected to happen - right?

Without this assumption it could be as simple as the logic in should_continue - if there are any tool_calls route to tools.
Wdyt?

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5158 **State:** closed **Merged:** No --- @sydney-runkle This fixes #5157. While working on the fix/tests I have observed that `FakeToolCallingModel` had no way to "stop producing tool calls" which was working only because the bug existed. (Think about it this way, it would keep producing the same tool call id - over and over, and the router would always assume the tool call is completed, and thus would end the execution). but I needed to reproduce the above case, without hitting the max graph recursion limit - so I added an optional arg to allow max generations with tool calls. After fixing the bug, I observed the test `test_post_model_hook_with_structured_output` fails on max graph recursion due to the above reason, so I took the liberty of fixing that test, resetting the agent/model state such that the two tested modes (invoke vs stream) are independent. I suggest splitting them to two tests though. As an aside - I do wonder - why even test for tool call completions in the `post_model_hook` router? And why does the logic assumed tools->post_model_hook is a possible path? This probably complicated the logic and is not expected to happen - right? Without this assumption it could be as simple as the logic in `should_continue` - if there are any tool_calls route to `tools`. Wdyt?
yindo added the pull-request label 2026-02-20 17:49:56 -05:00
yindo closed this issue 2026-02-20 17:49:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4271