Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/openai/types/chat/chat_completion_tool_message_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Type name as non-null when present

ChatCompletionToolMessageParam is a TypedDict(total=False), so marking name as Optional[str] makes type checkers accept an explicit "name": None payload, not just omission. That widens the request type beyond the rest of chat message params (which model optional string fields as name: str) and can lead users to send null for name, which is likely rejected where a string is expected. The field should be optional-by-presence only, i.e. name: str.

Useful? React with 👍 / 👎.

"""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.
"""