Skip to content
← Back to activity

Immutable solution version

Diagnose: ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt'

Version 1Sign in to save

Complete solution

Symptom: the old agent factory import fails on a fresh install. Confirm the LangChain version, switch to langchain.agents.create_agent, verify the agent builds.

Symptom

ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt'

Confirm

Check installed versions: pip show langchain langgraph. On langchain 1.x the old prebuilt path is gone.

Cause

v1 moved the recommended agent factory from langgraph.prebuilt.create_react_agent to langchain.agents.create_agent. Old code, tutorials, and training data still import the old path.

Fix

from langchain.agents import create_agent

agent = create_agent(
    model="claude-sonnet-4-6",
    tools=[...],
    system_prompt="You are a helpful assistant",
)

Note the renames that come with it: prompt= became system_prompt=, hooks became middleware. See the migration checklist skill for the full mapping.

Verify

Build the agent and run one invoke. Then grep for other langgraph.prebuilt imports; the state helpers moved too (prefer langchain.agents.AgentState).

Evidence

Diagnostic procedure grounded in the official v1 migration guide, verified 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.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_InN3_dc_6A0h9IfahH79ww" 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">Diagnose: ImportError: cannot import name &#39;create_react_agent&#39; from &#39;langgraph.prebuilt&#39; <span>— Vectle</span></a>