Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

AI and LLM integration · Decision guide

create_react_agent() rejects response_format with a TypeError

Short answer

TypeError: create_react_agent() got an unexpected keyword argument 'response_format' means the function you imported has no such parameter. Either langgraph is older than 0.2.62, the release that added it, or the import is LangChain's classic ReAct helper. Upgrade langgraph, or move to create_agent from langchain.agents, which accepts response_format. Applies to langgraph 1.2 and langchain 1.5.

  • Applies to langgraph 1.2.24 with langgraph-prebuilt 1.1.3, langchain 1.5.2, langchain-classic 1.0.8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Two different functions are called create_react_agent, and only one of them has ever accepted response_format. The error means the function you imported does not have that parameter: either it is the langgraph prebuilt one on a release older than 0.2.62, or it is LangChain's classic ReAct helper, which builds a prompt-driven agent and has no structured-output argument at all.

The way out is the same for both, in the long run. LangChain's create_agent takes response_format and returns the parsed result under structured_response. The langgraph prebuilt version is marked deprecated in current releases, so upgrading it only buys time.

Find your case

  1. If the import reads from langgraph.prebuilt and langgraph is oldThe parameter did not exist yet. Upgrade, then plan the move.
  2. If the import comes from langchain.agents (0.x) or langchain_classic.agents, and you pass a prompt templateYou are calling the classic helper; upgrading cannot add the argument.
  3. If you are ready to leave bothUse create_agent with a schema.

See what you actually imported

Print the installed versions and every import of the function. The module path in the import tells you which of the two functions you have.

Versions and imports

pip show langgraph langchain langchain-classic 2>/dev/null | grep -E "^(Name|Version)"
grep -rn "import.*create_react_agent" --include="*.py" .

An old langgraph

The langgraph 0.2.62 release notes list structured response support for create_react_agent as a new feature. On anything older the keyword raises the TypeError. You can ask the function directly whether it knows the parameter.

Check the signature, then upgrade

python -c "import inspect; from langgraph.prebuilt import create_react_agent as f; print('response_format' in inspect.signature(f).parameters)"
pip install -U langgraph

In the current langgraph source the prebuilt agent state classes carry deprecation notices that point to AgentState in langchain.agents, which is the same direction of travel.

The classic ReAct helper

The classic function in langchain_classic.agents takes a model, tools and a prompt, with optional parsing arguments, and returns a runnable. Its signature has no response_format, so no package upgrade makes the call valid. Print the signature to confirm.

Read the classic signature

python -c "import inspect; from langchain_classic.agents import create_react_agent as f; print(inspect.signature(f))"

The current route: create_agent

LangChain's structured-output page describes create_agent as capturing the schema-shaped answer, validating it and returning it in the structured_response key of the agent's state. response_format accepts a schema type directly, or a ToolStrategy or ProviderStrategy wrapper when you want to choose how the model is asked.

Structured output with a Pydantic schema

from pydantic import BaseModel
from langchain.agents import create_agent

class TicketSummary(BaseModel):
    title: str
    priority: str

agent = create_agent(
    model=llm,              # the chat model you already use
    tools=[search_tickets],
    response_format=TicketSummary,
)
result = agent.invoke({"messages": [{"role": "user", "content": "Summarise ticket 42"}]})
print(result["structured_response"])

Keeping the versions in step

  • Pin langgraph, langgraph-prebuilt and langchain together and upgrade them as one set.
  • Use one import path for agents across the codebase, so the classic and graph helpers cannot get mixed.
  • Add a test that builds the agent with response_format, so a wrong import or an old pin fails the build.

If the error turns into an ImportError for create_react_agent from langchain.agents, you are on LangChain 1.x, where that module exports create_agent instead.

In short

  • response_format exists on langgraph's version from 0.2.62, never on the classic one.
  • Print the signature to see which function you have.
  • create_agent is the maintained path and returns structured_response.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want a second pair of eyes on it?

Send me the error and what changed before it started. I reply within 24 hours.