{"record":{"id":"c3d661465be917e5","repo":"langchain-ai/langgraph","slug":"expected-model-to-be-a-chatmodel-or-runnablebind","errorCode":null,"errorMessage":"Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type}","messagePattern":"Expected `model` to be a ChatModel or RunnableBinding \\(e\\.g\\. model\\.bind_tools\\(\\.\\.\\.\\)\\), got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py","lineNumber":236,"sourceCode":"\n\ndef _get_model(model: LanguageModelLike) -> BaseChatModel:\n    \"\"\"Get the underlying model from a RunnableBinding or return the model itself.\"\"\"\n    if isinstance(model, RunnableSequence):\n        model = next(\n            (\n                step\n                for step in model.steps\n                if isinstance(step, (RunnableBinding, BaseChatModel))\n            ),\n            model,\n        )\n\n    if isinstance(model, RunnableBinding):\n        model = model.bound\n\n    if not isinstance(model, BaseChatModel):\n        raise TypeError(\n            f\"Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type(model)}\"\n        )\n\n    return model\n\n\ndef _validate_chat_history(\n    messages: Sequence[BaseMessage],\n) -> None:\n    \"\"\"Validate that all tool calls in AIMessages have a corresponding ToolMessage.\"\"\"\n    all_tool_calls = [\n        tool_call\n        for message in messages\n        if isinstance(message, AIMessage)\n        for tool_call in message.tool_calls\n    ]\n    tool_call_ids_with_results = {\n        message.tool_call_id for message in messages if isinstance(message, ToolMessage)","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L218-L254","documentation":"Raised by _get_model() when the object passed as `model` to create_react_agent, after unwrapping RunnableBinding/RunnableSequence, is still not a BaseChatModel. The agent requires an actual chat model to bind tools to; passing a plain string, an arbitrary Runnable, or a non-chat wrapper triggers this guard.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:236 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a chat model instance, e.g. `init_chat_model(\"openai:gpt-4o\")` or `ChatOpenAI(model=\"gpt-4o\")`","If binding tools, pass `model.bind_tools(tools)` so the value is a RunnableBinding around a BaseChatModel","If using a RunnableSequence, include the BaseChatModel step so it can be extracted"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}