[PR #6545] fix(langgraph): replace deprecated create_react_agent with create_agent #5110

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

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

State: closed
Merged: No


Description:

This PR updates the import and usage of the deprecated create_react_agent function. The function has been moved to langchain.agents as create_agent.

Changes:

  • Updated import:
# Old
from langchain.chains import create_react_agent  

# New
from langchain.agents import create_agent
  • Updated agent creation calls to match the new create_agent signature, including:

    • system_prompt instead of prompt

    • middleware instead of pre_model_hook/post_model_hook

  • Removed deprecation warnings and ensured compatibility with the latest LangChain release.

Example conversion:

# Old
from langgraph.prebuilt import create_react_agent
graph = create_react_agent(model, tools, prompt="You are a helpful assistant")

# New
from langchain.agents import create_agent
graph = create_agent(model, tools, system_prompt="You are a helpful assistan

Reason:

create_react_agent is deprecated in the latest LangChain release. Updating the import ensures compatibility with future versions and avoids runtime warnings.

Issue:

N/A (no linked issue)

Dependencies:

No new dependencies added. No changes to pyproject.toml or optional packages.

Lint and test:

All checks passed locally with:

  • make format
  • make lint
  • make test
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6545 **State:** closed **Merged:** No --- ## Description: This PR updates the import and usage of the deprecated `create_react_agent` function. The function has been moved to `langchain.agents` as `create_agent`. ### Changes: - Updated import: ```python # Old from langchain.chains import create_react_agent # New from langchain.agents import create_agent ``` * Updated agent creation calls to match the new `create_agent` signature, including: * `system_prompt` instead of `prompt` * `middleware` instead of `pre_model_hook`/`post_model_hook` * Removed deprecation warnings and ensured compatibility with the latest LangChain release. ### Example conversion: ```python # Old from langgraph.prebuilt import create_react_agent graph = create_react_agent(model, tools, prompt="You are a helpful assistant") # New from langchain.agents import create_agent graph = create_agent(model, tools, system_prompt="You are a helpful assistan ``` ### Reason: `create_react_agent` is deprecated in the latest LangChain release. Updating the import ensures compatibility with future versions and avoids runtime warnings. ### Issue: N/A (no linked issue) ### Dependencies: No new dependencies added. No changes to pyproject.toml or optional packages. ### Lint and test: All checks passed locally with: - make format - make lint - make test
yindo added the pull-request label 2026-02-20 17:51:14 -05:00
yindo closed this issue 2026-02-20 17:51:14 -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#5110