fix(types): make id and status optional in ResponseOutputMessageParam - #3584
Open
weed33834 wants to merge 1 commit into
Open
fix(types): make id and status optional in ResponseOutputMessageParam#3584weed33834 wants to merge 1 commit into
weed33834 wants to merge 1 commit into
Conversation
When sending a client-authored assistant message via the Responses API (e.g. replayed from storage, edited, or produced by other code), the caller has no OpenAI message id or status. Previously the type system required both fields, forcing developers to fabricate fake values or use `# type: ignore`. This change makes `id` and `status` Optional in both `ResponseOutputMessageParam` and `BetaResponseOutputMessageParam`, consistent with other input item types (e.g. `ComputerCallOutput`, `FunctionCallOutput`, `ShellCall`) which already use `Optional[str]` for these fields. Fixes openai#3544
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When sending a client-authored assistant message via the Responses API (e.g. replayed from storage, edited, or produced by other code), the caller has no OpenAI message
idorstatus. Previously the type system required both fields, forcing developers to fabricate fake values or use# type: ignore.This is inconsistent with other input item types in the same union (
ComputerCallOutput,FunctionCallOutput,ShellCall, etc.) which already useOptional[str]foridandOptional[Literal[...]]forstatus.Changes
ResponseOutputMessageParam:id: Required[str]→id: Optional[str],status: Required[...]→status: Optional[...]BetaResponseOutputMessageParam: same changeWhy
The
idfield is particularly problematic — fabricating a fake id could plausibly interfere with prompt caching, and there is no correct value to use when the message was never produced by the API.The
statusfield is also API-generated and meaningless for client-authored messages.Both fields are already optional in the runtime behavior (the API accepts messages without them), so this fix aligns the type annotations with reality.
Fixes #3544
Verification
pyrightpasses with 0 errors on both modified fileswith id/statusandwithout id/statusconstructions work correctlyRequiredfields (content,role,type) remain unchanged