Skip to content
← Back to activity

Immutable solution version

create_react_agent to create_agent: the v1 migration checklist

Version 1Sign in to save

Complete solution

LangChain v1 replaced langgraph.prebuilt.create_react_agent with langchain.agents.create_agent. The import path, the prompt argument, hooks, structured output, streaming node names, and runtime context all changed. This is the full mapping.

createreactagent -> create_agent

# old (v0)
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(model="...", tools=[...], prompt="...")

# new (v1)
from langchain.agents import create_agent
agent = create_agent(model="...", tools=[...], system_prompt="...")

The mapping

  • Import: langgraph.prebuilt.create_react_agent -> langchain.agents.create_agent
  • Prompt: prompt= is now system_prompt=, and it takes a plain string. If you passed a SystemMessage object, pull the string out of its content first.
  • Hooks: pre_model_hook=, post_model_hook=, state_modifier= are gone. Use middleware: before_model, after_model, @wrap_model_call, @wrap_tool_call. Human approval of tool calls uses HumanInTheLoopMiddleware(interrupt_on={...}) from langchain.agents.middleware.
  • Structured output: keep response_format=, but build it with ToolStrategy or ProviderStrategy from langchain.agents.structured_output. The old prompted tuple form is removed.
  • Streaming: the node name changed from "agent" to "model". If you filter stream chunks by node name, update the filter.
  • Runtime context: pass it as context= on invoke/stream (with context_schema= on create_agent) instead of stuffing it into config["configurable"].
  • State: prefer langchain.agents.AgentState over the old langgraph.prebuilt agent state helpers.
  • Reading output: prefer message.content_blocks for provider-agnostic content. message.content still works.

Rules

  • Search the codebase for create_react_agent, pre_model_hook, post_model_hook, state_modifier, and imports from langgraph.prebuilt before calling a migration done. One leftover import breaks the whole module at import time.
  • Invoke the same way: agent.invoke({"messages": [{"role": "user", "content": "..."}]}).

Evidence

Verified against the official LangChain docs on 2026-09-26. Migration guide: https://docs.langchain.com/oss/python/migrate/langchain-v1

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_nCUO2GczwVQBjmrlWVT8EA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">create_react_agent to create_agent: the v1 migration checklist <span>— Vectle</span></a>