{"record":{"id":"7743198ec66d60a8","repo":"langchain-ai/langchain","slug":"the-number-of-tool-outputs-len-tool-outputs-m","errorCode":null,"errorMessage":"The number of tool_outputs ({len(tool_outputs)}) must match the number of tool_calls ({len(openai_tool_calls)}). Got {len(tool_outputs)} output(s) for {len(openai_tool_calls)} tool call(s).","messagePattern":"The number of tool_outputs \\((.+?)\\) must match the number of tool_calls \\((.+?)\\)\\. Got (.+?) output\\(s\\) for (.+?) tool call\\(s\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/function_calling.py","lineNumber":722,"sourceCode":"                # of the Pydantic model. This is implicit in the API right now,\n                # and will be improved over time.\n                \"name\": tool_call.__class__.__name__,\n                \"arguments\": tool_call.model_dump_json(),\n            },\n        }\n        for tool_call in tool_calls\n    ]\n\n    messages.append(\n        AIMessage(content=\"\", additional_kwargs={\"tool_calls\": openai_tool_calls})\n    )\n    if tool_outputs is not None and len(tool_outputs) != len(openai_tool_calls):\n        msg = (\n            f\"The number of tool_outputs ({len(tool_outputs)}) must match the number \"\n            f\"of tool_calls ({len(openai_tool_calls)}). Got {len(tool_outputs)} \"\n            f\"output(s) for {len(openai_tool_calls)} tool call(s).\"\n        )\n        raise ValueError(msg)\n    tool_outputs = tool_outputs or [\"You have correctly called this tool.\"] * len(\n        openai_tool_calls\n    )\n    for output, tool_call_dict in zip(tool_outputs, openai_tool_calls, strict=False):\n        messages.append(ToolMessage(content=output, tool_call_id=tool_call_dict[\"id\"]))\n\n    if ai_response:\n        messages.append(AIMessage(content=ai_response))\n    return messages\n\n\n_MIN_DOCSTRING_BLOCKS = 2\n\n\ndef _parse_google_docstring(\n    docstring: str | None,\n    args: list[str],\n    *,","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/function_calling.py#L704-L740","documentation":"Error \"The number of tool_outputs ({len(tool_outputs)}) must match the number of tool_calls ({len(openai_tool_calls)}). Got {len(tool_outputs)} output(s) for {len(openai_tool_calls)} tool call(s).\" thrown in langchain-ai/langchain.","triggerScenarios":"Raised when the list of tool_outputs supplied (e.g. for submitting tool results) does not match the number of tool_calls issued by the model.","commonSituations":"See trigger scenarios.","solutions":["Provide exactly one tool_output per tool_call, in matching order.","Check the model response: if it emitted N tool calls, supply N tool outputs."],"exampleFix":"tool_outputs = [result_for_call_0, result_for_call_1]  # same length as tool_calls","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}