fix: add missing edge from generate_structured_response to END#6733
Open
saakshigupta2002 wants to merge 1 commit intolangchain-ai:mainfrom
Open
fix: add missing edge from generate_structured_response to END#6733saakshigupta2002 wants to merge 1 commit intolangchain-ai:mainfrom
saakshigupta2002 wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
When response_format is provided to create_react_agent, the generate_structured_response node was added to the graph but no outgoing edge to END was defined. This caused the graph to not terminate properly after generating the structured response, potentially leading to infinite loops until the recursion limit. This fix adds an explicit edge from generate_structured_response to END to ensure proper graph termination. Fixes langchain-ai#6731
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate_structured_responsenode toENDincreate_react_agentresponse_formatparameterProblem
When
response_formatis provided tocreate_react_agent, thegenerate_structured_responsenode is added to the graph but no outgoing edge toENDis defined. This causes the graph to not terminate properly after generating the structured response, potentially leading to infinite loops until the recursion limit is hit.Solution
Added an explicit edge from
generate_structured_responsetoENDafter the node is added to the workflow (line 901-902 inchat_agent_executor.py):This ensures the graph properly terminates after the structured response is generated.
Test plan
make test-fast- 189 tests passed)test_react_agent_with_structured_response,test_dynamic_model_with_structured_response,test_post_model_hook_with_structured_output)Fixes #6731