fix(types): add optional name field to ChatCompletionToolMessageParam#2945
fix(types): add optional name field to ChatCompletionToolMessageParam#2945DanielDerefaka wants to merge 1 commit intoopenai:mainfrom
name field to ChatCompletionToolMessageParam#2945Conversation
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 openai#1078
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7086635fe3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| tool_call_id: Required[str] | ||
| """Tool call that this message is responding to.""" | ||
|
|
||
| name: Optional[str] |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Fixes #1078
The OpenAI docs for parallel function calling include a
namefield in tool result messages:However,
ChatCompletionToolMessageParamdid not include this field, causingmypy/pyrighttype errors for users following the official docs.Changes
name: Optional[str]field toChatCompletionToolMessageParamnamefield already present onChatCompletionFunctionMessageParamVerification
Passes
mypyandpyrightwithout errors.