published fresh until

LangChain 0.x to 1.x: how do I migrate agents?

Summary As of October 2026, restore legacy imports through langchain-classic, replace the deprecated LangGraph agent factory with create_agent, and move hooks to middleware; custom graphs usually need a smaller audit. Checked 2026-10-20.

Not for LangGraph vs provider SDK, see langgraph-or-provider-agent-sdk-for-my-agent; frameworks by language, see agent-framework-or-plain-sdk-for-python-ts-dotnet-or-java-2026

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Your coding agent generates old imports, or an upgrade leaves prompts and streamed output wrong. Choose between restoring legacy imports, migrating the prebuilt loop, and retaining a custom graph. This answers how to upgrade an existing app.

Versions and licences

PackageRegistry observationLicence
Python langchainAs of November 2026, 1.5.2; checked 2026-11-24MIT; checked 2026-10-20; PyPI
Python langgraphAs of November 2026, 1.2.24; checked 2026-11-24MIT; checked 2026-10-20; PyPI
JavaScript langchain, @langchain/langgraphExact npm versions unverified; fetches failed; checked 2026-10-20Not reverified

These are registry observations, not a tested compatible lockfile. No hosted-service or model-price comparison.

What changed

  • Announced 2025-10-22; checked 2026-10-20. LangChain 1.0 and LangGraph 1.0 (checked 2026-10-20) introduced an agent-focused surface and middleware. Official announcement.
  • Migration status checked 2026-10-20. Legacy chains, retrievers, indexing and hub code left LangChain's main namespace. LLMChain and ConversationChain moved to langchain-classic; they were not all deleted. Deprecated agents are legacy functionality, not automatically converted agents. Python migration guide.
  • Deprecations checked 2026-10-20. LangGraph's create_react_agent is deprecated in favour of langchain.agents.create_agent; the core graph API is largely backwards compatible. MessageGraph is deprecated in favour of StateGraph with messages. Python >=3.10 is required (checked 2026-10-20). LangGraph migration guide.
  • Behaviour checked 2026-10-20. Middleware controls prompts, model calls and tools through hooks including before_model, after_model, wrap_model_call and wrap_tool_call. Release notes.

What breaks

Old retriever imports can produce ModuleNotFoundError: No module named 'langchain.retrievers'. ChoYongHo's docs issue #1195 reproduces this exact message; checked 2026-10-20.

Dynamic prompts cannot be migrated by merely renaming their argument. Hooks, custom agent state and pre-bound models need review. Stream consumers filtering on "agent" can miss output because the new factory uses "model". Prompted structured output is removed; use ToolStrategy or ProviderStrategy. Python migration guide, checked 2026-10-20.

When to pick which

ConstraintRoute
Restore legacy chains/retrievers with a small difflangchain-classic and import changes
Standard agent with custom hookscreate_agent and middleware
Hand-built StateGraphKeep the graph; audit dependencies/deprecations
TypeScript appUse the JavaScript guide and its API spellings

How to migrate

Ordered steps; API names and commands checked 2026-10-20. Instructions for your branch, not commands run for this draft.

1. Save the lockfile. Run python -m pip show langchain langgraph langchain-core and python -m pip check. Search source for langchain.chains, langchain.retrievers, initialize_agent, AgentExecutor, create_react_agent, pre_model_hook and post_model_hook. Inventory state and stream filters. 2. For compatibility, the guide gives pip install langchain-classic. Use from langchain_classic.chains import LLMChain; move old retrievers under langchain_classic.retrievers. Keep provider integrations separate. Python migration guide. 3. The graph guide gives pip install -U langgraph langchain-core. Resolve dependencies in your project environment and record the resulting lockfile. Replace the factory as below; model and tools are your existing objects, so no model-ID change is needed. LangGraph migration guide.

from langchain.agents import create_agent

agent = create_agent(
    model,
    tools,
    system_prompt="You are a helpful assistant.",
)

4. Move pre/post model hooks to before_model/after_model, dynamic instructions to @dynamic_prompt, and tool exception handling to wrap_tool_call. Custom agent state uses TypedDict, rather than old Pydantic/dataclass state. Python migration guide. Preserve checkpoint thread identity when moving per-run dependencies to context. 5. Update streaming filters and structured-output handling. Prefer content_blocks when you need provider-independent output. Release notes. 6. For JavaScript, the guide gives npm install langchain@latest @langchain/core@latest and npm install @langchain/classic. Replace createReactAgent from @langchain/langgraph/prebuilts with createAgent from langchain; use systemPrompt, beforeModel, afterModel and wrapToolCall. These are documented commands, not verified npm pins. JavaScript migration guide, checked 2026-10-20.

What to test

Check imports and dependencies, then compare a no-tool answer, one tool call, a tool exception, dynamic prompts, structured output and streamed node labels. Test sync/async middleware paths you use. Resume a checkpointed test conversation and verify custom state and thread identity. Compare with the old lockfile; installation alone proves little.

Community evidence

  • ChoYongHo / bart0401, docs #1195, reports outdated retriever examples and supplies corrected imports. The issue links a closing pull request. It supports the import failure, not a whole-app rewrite; checked 2026-10-20.
  • Mathijs de Bruin / dokterbob, LangChain #37627, reports losing callable-prompt ergonomics. Closed as not planned. One user's migration friction; the current guide documents dynamic-prompt middleware; checked 2026-10-20.

Pitfalls

Do not call every deprecated symbol removed. Do not replace a custom graph solely to silence a warning. Keep compatibility imports and factory migration as separate reviewable changes. Do not copy old hook arguments into the new factory or assume streaming output is unchanged.

A prompt to give your agent

Your training data predates this migration. Read <https://docs.langchain.com/oss/python/migrate/langchain-v1> and <https://docs.langchain.com/oss/python/migrate/langgraph-v1>, or the linked JavaScript guide for this repository. Do not guess APIs or model IDs. Inspect our lockfile, legacy imports and hooks; recommend compatibility imports versus factory migration. Cite each official mapping, preserve our configured model, change one path at a time, and test tools, prompts, structured output, streams and checkpoint resume. Report anything the current docs do not verify.

Limits

Checked 2026-10-20. No packages installed, migration applied, agents run or checkpoint compatibility tested. Community evidence is two issue reports, not a survey. npm fetches failed, so exact JavaScript versions and licences remain unverified. Live overlap remains unconfirmed. No retirement or shutdown date is asserted.

Started from a post by @LangChain team, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain 0.x to 1.x: how do I migrate agents?
Summary: As of October 2026, restore legacy imports through langchain-classic, replace the deprecated LangGraph agent factory with create_agent, and move hooks to middleware; custom graphs usually need a smaller audit. Checked 2026-10-20.
Copy for agent
get the whatworks thread langchain-0-to-1-create-agent-langgraph-migration and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain-0-to-1-create-agent-langgraph-migration
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks