{"record":{"id":"c379ffa3576a739a","repo":"langchain-ai/langgraph","slug":"tool-name-returned-a-list-with-count-messages","errorCode":null,"errorMessage":"Tool {name} returned a list with {count} messages bound to tool_call_id '{id}'; expected exactly one terminating ToolMessage.","messagePattern":"Tool (.+?) returned a list with (.+?) messages bound to tool_call_id '(.+?)'; expected exactly one terminating ToolMessage\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/prebuilt/langgraph/prebuilt/tool_node.py","lineNumber":1485,"sourceCode":"        expected_id = tool_call[\"id\"]\n\n        terminator_count = 0\n        for item in response:\n            if isinstance(item, ToolMessage):\n                if item.tool_call_id == expected_id:\n                    terminator_count += 1\n            elif isinstance(item, Command) and isinstance(item.update, dict):\n                for msg in item.update.get(self._messages_key, []):\n                    if isinstance(msg, ToolMessage) and msg.tool_call_id == expected_id:\n                        terminator_count += 1\n\n        if terminator_count != 1:\n            msg = (\n                f\"Tool {tool_call['name']} returned a list with \"\n                f\"{terminator_count} messages bound to tool_call_id \"\n                f\"{expected_id!r}; expected exactly one terminating ToolMessage.\"\n            )\n            raise ValueError(msg)\n\n        # Per-Command normalization still runs, but the list-level count above\n        # already guarantees exactly one terminator, so individual Commands may\n        # lack one.\n        validated: list[Command | ToolMessage] = []\n        for item in response:\n            if isinstance(item, Command):\n                validated.append(\n                    self._validate_tool_command(\n                        item, tool_call, input_type, require_terminator=False\n                    )\n                )\n            else:\n                item.content = cast(\"str | list\", msg_content_output(item.content))\n                validated.append(item)\n        return validated\n\n    def _validate_tool_command(","sourceCodeStart":1467,"sourceCodeEnd":1503,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/prebuilt/langgraph/prebuilt/tool_node.py#L1467-L1503","documentation":"Error \"Tool {name} returned a list with {count} messages bound to tool_call_id '{id}'; expected exactly one terminating ToolMessage.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1485 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"}