Skip to content

Update langgraph vendor agent for new create_agent API#6

Closed
sachin-patro wants to merge 3 commits into
mainfrom
fix/langgraph-vendor-create-agent
Closed

Update langgraph vendor agent for new create_agent API#6
sachin-patro wants to merge 3 commits into
mainfrom
fix/langgraph-vendor-create-agent

Conversation

@sachin-patro
Copy link
Copy Markdown
Contributor

Summary

  • LangChain moved from langgraph.prebuilt.create_react_agent to langchain.agents.create_agent with a different kwarg (system_prompt= instead of prompt=)
  • Added import fallback in plan_and_execute.py so the cookbook works with both old and new LangChain versions (same pattern the email agent cookbook already uses)
  • Updated README to remove hardcoded create_react_agent reference

Test plan

  • test_build_graph_calls_create_fn_with_correct_kwarg — verifies system_prompt= is passed when using the new API
  • test_build_graph_calls_legacy_fn_with_prompt_kwarg — verifies prompt= is passed when falling back to old API
  • test_import_fallback_to_langgraph_prebuilt — verifies fallback resolves to langgraph.prebuilt.create_react_agent when langchain.agents.create_agent is unavailable
  • Existing test_vendor_agent_populates_artifacts and test_vendor_agent_handles_empty_output still pass
  • All 5 tests passing

🤖 Generated with Claude Code

sachin-patro and others added 3 commits April 5, 2026 22:44
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant