Update langgraph vendor agent for new create_agent API#6
Closed
sachin-patro wants to merge 3 commits into
Closed
Conversation
The LangChain agents API has moved from langgraph.prebuilt.create_react_agent to langchain.agents.create_agent with a different kwarg (system_prompt= instead of prompt=). Add an import fallback so the cookbook works with both old and new LangChain versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use getattr() instead of direct attribute access so mypy doesn't complain about accessing .create_agent on an object return type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
langgraph.prebuilt.create_react_agenttolangchain.agents.create_agentwith a different kwarg (system_prompt=instead ofprompt=)plan_and_execute.pyso the cookbook works with both old and new LangChain versions (same pattern the email agent cookbook already uses)create_react_agentreferenceTest plan
test_build_graph_calls_create_fn_with_correct_kwarg— verifiessystem_prompt=is passed when using the new APItest_build_graph_calls_legacy_fn_with_prompt_kwarg— verifiesprompt=is passed when falling back to old APItest_import_fallback_to_langgraph_prebuilt— verifies fallback resolves tolanggraph.prebuilt.create_react_agentwhenlangchain.agents.create_agentis unavailabletest_vendor_agent_populates_artifactsandtest_vendor_agent_handles_empty_outputstill pass🤖 Generated with Claude Code