{"record":{"id":"e9089b22375656fc","repo":"langchain-ai/langgraph","slug":"invalid-chat-history","errorCode":"INVALID_CHAT_HISTORY","errorMessage":"Found AIMessages with tool_calls that do not have a corresponding ToolMessage. Here are the first few of those tool calls: {first3}. Every tool call (LLM requesting to call a tool) in the message history MUST have a corresponding ToolMessage (result of a tool invocation to return to the LLM) - this is required by most LLM providers.","messagePattern":"Found AIMessages with tool_calls that do not have a corresponding ToolMessage\\. Here are the first few of those tool calls: (.+?)\\. Every tool call \\(LLM requesting to call a tool\\) in the message history MUST have a corresponding ToolMessage \\(result of a tool invocation to return to the LLM\\) - this is required by most LLM providers\\.","errorType":"error_code","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py","lineNumber":271,"sourceCode":"    tool_call_ids_with_results = {\n        message.tool_call_id for message in messages if isinstance(message, ToolMessage)\n    }\n    tool_calls_without_results = [\n        tool_call\n        for tool_call in all_tool_calls\n        if tool_call[\"id\"] not in tool_call_ids_with_results\n    ]\n    if not tool_calls_without_results:\n        return\n\n    error_message = create_error_message(\n        message=\"Found AIMessages with tool_calls that do not have a corresponding ToolMessage. \"\n        f\"Here are the first few of those tool calls: {tool_calls_without_results[:3]}.\\n\\n\"\n        \"Every tool call (LLM requesting to call a tool) in the message history MUST have a corresponding ToolMessage \"\n        \"(result of a tool invocation to return to the LLM) - this is required by most LLM providers.\",\n        error_code=ErrorCode.INVALID_CHAT_HISTORY,\n    )\n    raise ValueError(error_message)\n\n\n@deprecated(\n    \"create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`.\",\n    category=LangGraphDeprecatedSinceV10,\n)\ndef create_react_agent(\n    model: str\n    | LanguageModelLike\n    | Callable[[StateSchema, Runtime[ContextT]], BaseChatModel]\n    | Callable[[StateSchema, Runtime[ContextT]], Awaitable[BaseChatModel]]\n    | Callable[\n        [StateSchema, Runtime[ContextT]], Runnable[LanguageModelInput, BaseMessage]\n    ]\n    | Callable[\n        [StateSchema, Runtime[ContextT]],\n        Awaitable[Runnable[LanguageModelInput, BaseMessage]],\n    ],","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L253-L289","documentation":"Error \"Found AIMessages with tool_calls that do not have a corresponding ToolMessage. Here are the first few of those tool calls: {first3}. Every tool call (LLM requesting to call a tool) in the message history MUST have a corresponding ToolMessage (result of a tool invocation to return to the LLM) - this is required by most LLM providers.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:271 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"}