{"record":{"id":"f0d86c6d5af33352","repo":"langchain-ai/langgraph","slug":"expected-input-to-call-model-to-have-llm-input-me","errorCode":null,"errorMessage":"Expected input to call_model to have 'llm_input_messages' or 'messages' key, but got {state}","messagePattern":"Expected input to call_model to have 'llm_input_messages' or 'messages' key, but got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py","lineNumber":649,"sourceCode":"            elif remaining_steps < 2 and has_tool_calls:\n                return True\n\n        return False\n\n    def _get_model_input_state(state: StateSchema) -> StateSchema:\n        if pre_model_hook is not None:\n            messages = (\n                _get_state_value(state, \"llm_input_messages\")\n            ) or _get_state_value(state, \"messages\")\n            error_msg = f\"Expected input to call_model to have 'llm_input_messages' or 'messages' key, but got {state}\"\n        else:\n            messages = _get_state_value(state, \"messages\")\n            error_msg = (\n                f\"Expected input to call_model to have 'messages' key, but got {state}\"\n            )\n\n        if messages is None:\n            raise ValueError(error_msg)\n\n        _validate_chat_history(messages)\n        # we're passing messages under `messages` key, as this is expected by the prompt\n        if isinstance(state_schema, type) and issubclass(state_schema, BaseModel):\n            state.messages = messages  # type: ignore\n        else:\n            state[\"messages\"] = messages  # type: ignore\n\n        return state\n\n    # Define the function that calls the model\n    def call_model(\n        state: StateSchema, runtime: Runtime[ContextT], config: RunnableConfig\n    ) -> StateSchema:\n        if is_async_dynamic_model:\n            msg = (\n                \"Async model callable provided but agent invoked synchronously. \"\n                \"Use agent.ainvoke() or agent.astream(), or \"","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L631-L667","documentation":"Error \"Expected input to call_model to have 'llm_input_messages' or 'messages' key, but got {state}\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:649 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"}