{"record":{"id":"80eac77f26efb0c1","repo":"langchain-ai/langgraph","slug":"missing-required-key-s-missing-keys-in-state-sc","errorCode":null,"errorMessage":"Missing required key(s) {missing_keys} in state_schema","messagePattern":"Missing required key\\(s\\) (.+?) in state_schema","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py","lineNumber":545,"sourceCode":"\n    if len(deprecated_kwargs) > 0:\n        raise TypeError(\n            f\"create_react_agent() got unexpected keyword arguments: {deprecated_kwargs}\"\n        )\n\n    if version not in (\"v1\", \"v2\"):\n        raise ValueError(\n            f\"Invalid version {version}. Supported versions are 'v1' and 'v2'.\"\n        )\n\n    if state_schema is not None:\n        required_keys = {\"messages\", \"remaining_steps\"}\n        if response_format is not None:\n            required_keys.add(\"structured_response\")\n\n        schema_keys = set(get_type_hints(state_schema))\n        if missing_keys := required_keys - set(schema_keys):\n            raise ValueError(f\"Missing required key(s) {missing_keys} in state_schema\")\n\n    if state_schema is None:\n        state_schema = (\n            AgentStateWithStructuredResponse\n            if response_format is not None\n            else AgentState\n        )\n\n    llm_builtin_tools: list[dict] = []\n    if isinstance(tools, ToolNode):\n        tool_classes = list(tools.tools_by_name.values())\n        tool_node = tools\n    else:\n        llm_builtin_tools = [t for t in tools if isinstance(t, dict)]\n        tool_node = ToolNode([t for t in tools if not isinstance(t, dict)])\n        tool_classes = list(tool_node.tools_by_name.values())\n\n    is_dynamic_model = not isinstance(model, (str, Runnable)) and callable(model)","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L527-L563","documentation":"Raised by create_react_agent when a custom `state_schema` is supplied but its type hints omit keys the agent machinery requires: 'messages', 'remaining_steps', and (when response_format is set) 'structured_response'. The schema is introspected with get_type_hints and must be a superset of these keys.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:545 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the missing annotated fields to your state_schema, e.g. `messages: Annotated[list[AnyMessage], add_messages]` and `remaining_steps: int`","If using response_format, also add `structured_response: Any`","Consider subclassing the agent's built-in schema instead of defining one from scratch"],"exampleFix":null,"handlingStrategy":"validation","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"}