{"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":"Error \"Expected `model` to be a ChatModel or RunnableBinding (e.g. model.bind_tools(...)), got {type}\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:236 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}