langchain-ai/langgraph · error · TypeError
Expected `model` to be a ChatModel or RunnableBinding (e.g.
Error message
Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type} What it means
Error "Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type}" thrown in langchain-ai/langgraph.
Source
Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:236
def _get_model(model: LanguageModelLike) -> BaseChatModel:
"""Get the underlying model from a RunnableBinding or return the model itself."""
if isinstance(model, RunnableSequence):
model = next(
(
step
for step in model.steps
if isinstance(step, (RunnableBinding, BaseChatModel))
),
model,
)
if isinstance(model, RunnableBinding):
model = model.bound
if not isinstance(model, BaseChatModel):
raise TypeError(
f"Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type(model)}"
)
return model
def _validate_chat_history(
messages: Sequence[BaseMessage],
) -> None:
"""Validate that all tool calls in AIMessages have a corresponding ToolMessage."""
all_tool_calls = [
tool_call
for message in messages
if isinstance(message, AIMessage)
for tool_call in message.tool_calls
]
tool_call_ids_with_results = {
message.tool_call_id for message in messages if isinstance(message, ToolMessage)View on GitHub (pinned to 38031739e5)
When it happens
Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:236 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/c3d661465be917e5.
Report an issue: GitHub.