Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/langchain-common-errors

@0d57af8
Run it yourself

Paste-match catalog of 14 real LangChain 1.0 / LangGraph 1.0 exceptions with named causes and named fixes, plus a triage decision tree. Use when you have a traceback and want the specific fix, not speculative documentation. Covers ImportError (0.2/0.3 → 1.0 migration), AttributeError on AIMessage.content, KeyError in LCEL and prompts, GraphRecursionError, silent thread_id memory loss, JSON-serialization crashes, and graphs that halt without reaching END. Trigger with "langchain error", "langgraph traceback", "OutputParserException", "GraphRecursionError", "ImportError langchain", "AttributeError AIMessage content".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/langchain-common-errors

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referenceserrorsimport-migration.md

≈1.9k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Import & Migration Errors (0.2 / 0.3 → 1.0)

Pain-catalog anchors: P38, P39, P40, P41, P42, P66.

Every error below was raised by LangChain 0.2/0.3-era code running against pinned langchain-core 1.0.x. The top-level re-exports from the langchain meta-package were removed in 1.0. Provider integrations, agent factories, legacy chain classes, and ConversationBufferMemory now live in separate packages.

Last verified against langchain-core==1.0.0, langchain==1.0.0, langgraph==1.0.0, langchain-openai==1.0.0, langchain-anthropic==1.0.0, anthropic==0.42.0.


E01 — ImportError: cannot import name 'ChatOpenAI' from 'langchain.chat_models'

Pain: P38

Before:

from langchain.chat_models import ChatOpenAI  # 0.2 path
from langchain.chat_models import ChatAnthropic  # 0.2 path

Cause: Provider integrations moved to langchain-<provider> packages in 0.3. The top-level re-exports from langchain.chat_models and langchain.llms were removed in 1.0.

After:

from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_google_genai import ChatGoogleGenerativeAI

Codemod: python -m langchain_cli migrate path/to/src/ rewrites the imports. Run pip install langchain-cli>=0.1 first. Re-run tests — imports will now succeed but you may hit E04 (AIMessage.content shape) and E05 (list[Union] structured output) next.

Install: pip install "langchain-openai>=1.0,<2.0" "langchain-anthropic>=1.0,<2.0" "langchain-google-genai>=1.0,<2.0".


E02 — AttributeError: module 'langchain' has no attribute 'LLMChain'

Pain: P39

Before:

from langchain.chains import LLMChain
chain = LLMChain(llm=llm, prompt=prompt)
result = chain.run({"input": text})

Cause: LLMChain (and SimpleSequentialChain, SequentialChain, TransformChain, etc.) were deprecated in 0.3 and removed in 1.0 in favor of LCEL composition. The 1.0 langchain package has no chains module.

After:

from langchain_core.output_parsers import StrOutputParser
chain = prompt | llm | StrOutputParser()
result = chain.invoke({"input": text})

Notes: If you need fallbacks, use chain.with_fallbacks([backup]). If you need retries, use chain.with_retry(...). .run(x) became .invoke({"input": x}); single-positional-string input is gone.


E03 — ImportError: cannot import name 'ConversationBufferMemory'

Pain: P40

Before:

from langchain.memory import ConversationBufferMemory
memory = ConversationBufferMemory(memory_key="history")

Cause: All ConversationBufferMemory, ConversationSummaryMemory, ConversationTokenBufferMemory, VectorStoreRetrieverMemory classes deprecated in 0.3, removed in 1.0. LangGraph checkpointing is the supported replacement for multi-turn chat memory.

After:

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.prebuilt import create_react_agent

checkpointer = InMemorySaver()  # or PostgresSaver / SqliteSaver
agent = create_react_agent(model=llm, tools=tools, checkpointer=checkpointer)
result = agent.invoke(
    {"messages": [("user", "hi")]},
    config={"configurable": {"thread_id": "user-42"}},
)

Notes: thread_id is required — without it every invocation gets a fresh state (see E12). For process-restart persistence use PostgresSaver or SqliteSaver, not InMemorySaver.


E04 — ImportError: cannot import name 'initialize_agent'

Pain: P41

Before:

from langchain.agents import initialize_agent, AgentType
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
)

Cause: initialize_agent, AgentType, create_openai_functions_agent, create_structured_chat_agent, and most legacy agent factories are removed in 1.0. AgentExecutor is still importable but LangGraph's create_react_agent is the supported path for new code.

After:

from langgraph.prebuilt import create_react_agent
from langgraph.checkpoint.memory import InMemorySaver

agent = create_react_agent(
    model=llm,
    tools=tools,
    checkpointer=InMemorySaver(),
)

Notes: create_react_agent uses provider-native tool calling (no free-text ReAct parsing) and raises on tool errors by default, unlike legacy AgentExecutor which swallowed them as empty strings (E08). Default recursion_limit=25 — see E13.


E05 — AttributeError: 'AgentAction' object has no attribute 'tool_name' (or inverse .tool)

Pain: P42

Before:

result = executor.invoke({"input": q})
for action, observation in result["intermediate_steps"]:
    print(action.tool, action.tool_input)  # 0.2 / 0.3 shape

Cause: Legacy AgentAction / AgentFinish tuple shape was replaced by ToolCall objects in 1.0. Fields renamed: .tool → .tool_name, .tool_input → .args, .log removed. LangGraph agents emit messages with .tool_calls instead of a separate intermediate_steps key.

After (LangGraph create_react_agent):

result = agent.invoke({"messages": [("user", q)]}, config=cfg)
for msg in result["messages"]:
    for tool_call in getattr(msg, "tool_calls", []) or []:
        print(tool_call["name"], tool_call["args"])

Notes: When migrating, grep -rn "intermediate_steps" src/ and grep -rn "\.tool_input" src/ to find all call-sites. Both shapes compile, so type-checking will not catch this — only runtime AttributeError.


E06 — KeyError: 'input' inside tool_use block parsing (after upgrading langchain-anthropic)

Pain: P66

Before: langchain-anthropic==0.3.x pinned alongside langchain-anthropic==1.0.

Cause: langchain-anthropic >= 1.0 requires anthropic >= 0.40. The Anthropic SDK's tool_use block schema changed; pinning to an old anthropic breaks AIMessage.content parsing for tool calls. Chat-only responses still work — tool calling is the first place it breaks.

After:

pip install "langchain-anthropic>=1.0,<2.0" "anthropic>=0.42,<1.0"

Pin both in the same pip install or pyproject.toml bump — upgrading one without the other is the bug.

Notes: Sanity-check with:

import anthropic, langchain_anthropic
print(anthropic.__version__, langchain_anthropic.__version__)
# Must be anthropic >= 0.40 and langchain-anthropic >= 1.0

Codemod-driven migration checklist

  1. pip install "langchain-cli>=0.1" (dev dep).
  2. python -m langchain_cli migrate . — rewrites imports for E01.
  3. Manually handle E02/E03/E04 (the codemod does not rewrite LLMChain, memory, or agent construction).
  4. grep -rn "intermediate_steps\|AgentAction\|AgentType\|initialize_agent\|LLMChain\|ConversationBuffer\|from langchain\.chat_models\|from langchain\.llms" src/ → every hit is a manual fix.
  5. Pin all three: langchain-core, langchain, langgraph, plus any provider packages, to the same 1.0.x major.
  6. pytest -x — expect E07-E14 from the other reference files next. That is normal on a 0.2/0.3 → 1.0 jump.

Sources

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill is a technical reference guide for troubleshooting common LangChain and LangGraph errors. It provides cataloged fixes for various exceptions and migration issues encountered in LangChain 1.0 environments. No security risks were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
What it can do
Reads files
version
2.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatibility
Designed for Claude Code
All 2 allowed tools
ReadGrep
Other metadata
tags
[
  "saas",
  "langchain",
  "langgraph",
  "python",
  "langchain-1.0",
  "errors",
  "troubleshooting",
  "debugging"
]

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/langchain-common-errors