From 7086635fe3a96368df17afd8436b0bef46680ca0 Mon Sep 17 00:00:00 2001 From: Daniel Derefaka Date: Mon, 9 Mar 2026 00:28:50 +0000 Subject: [PATCH] fix(types): add optional `name` field to ChatCompletionToolMessageParam The OpenAI docs for parallel function calling include a `name` field in tool result messages, but `ChatCompletionToolMessageParam` did not expose this field, causing mypy/pyright type errors when users followed the docs. Adds an optional `name: Optional[str]` field consistent with other message param types and the API's own documentation examples. Fixes #1078 --- .../types/chat/chat_completion_tool_message_param.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/openai/types/chat/chat_completion_tool_message_param.py b/src/openai/types/chat/chat_completion_tool_message_param.py index eb5e270e47..c165c3cca8 100644 --- a/src/openai/types/chat/chat_completion_tool_message_param.py +++ b/src/openai/types/chat/chat_completion_tool_message_param.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Optional, Union, Iterable from typing_extensions import Literal, Required, TypedDict from .chat_completion_content_part_text_param import ChatCompletionContentPartTextParam @@ -19,3 +19,13 @@ class ChatCompletionToolMessageParam(TypedDict, total=False): tool_call_id: Required[str] """Tool call that this message is responding to.""" + + name: Optional[str] + """The name of the tool that was called. + + This field is optional and mirrors the `name` field present on other message + types (e.g. ``ChatCompletionFunctionMessageParam``). Including the tool name + can improve clarity when multiple tools are used in a single conversation turn, + and is consistent with OpenAI's own documentation examples for parallel + function calling. + """