Bug: Add missing name field to ResponseFunctionCallArgumentsDoneEvent#420
Merged
Merged
Conversation
…tsDoneEvent Per OpenAI's docs the response.function_call_arguments.done streaming event carries a `name` field identifying the function whose arguments were finalized. The OpenAPI spec used to generate Components.swift is missing it, so callers couldn't read the function name from this event. Extract `ResponseFunctionCallArgumentsDoneEvent` into Public/Schemas/Edited/ with `name: String?` added (kept optional for forward-compat with servers that haven't shipped the field), following the same pattern already used for ResponseMCPCallArgumentsDoneEvent. Update the ResponseStreamEvent facade to decode the extracted type ahead of the generated raw event so `name` is preserved on the public `.functionCallArguments(.done(_))` case. Closes #409 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nezhyborets
approved these changes
May 18, 2026
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.
What
The
response.function_call_arguments.donestreaming event is documented by OpenAI as carrying anamefield identifying the function whose arguments have been finalized:{ "type": "response.function_call_arguments.done", "item_id": "item-abc", "name": "get_weather", "output_index": 1, "arguments": "{ \"arg\": 123 }", "sequence_number": 1 }The generated
Components.Schemas.ResponseFunctionCallArgumentsDoneEventis missing it (the upstream OpenAPI spec lags), so SDK users couldn't read the function name from this event.This PR:
Sources/OpenAI/Public/Schemas/Edited/ResponseFunctionCallArgumentsDoneEvent.swiftwith a newpublic var name: Swift.String?field, following the documented pattern in CONTRIBUTING.md ("Extracting a generated Type") and the existing precedent forResponseMCPCallArgumentsDoneEvent.ResponseStreamEventfacade so.functionCallArguments(.done(_))carries the extracted type. Adds an early decode block (mirroring the MCP one) so JSON withnameround-trips correctly. Preserves the existingrawEvent.value19fallback by converting from the generated type to the new one (withname: nil).Why
Closes #409. Function-call routing on the Responses API requires knowing which function the arguments belong to. Without
name, consumers had to track it externally via the surroundingoutput_item.addedevent, which is brittle.Affected Areas
Sources/OpenAI/Public/Schemas/Edited/ResponseFunctionCallArgumentsDoneEvent.swiftSources/OpenAI/Public/Schemas/Facade/ResponseStreamEvent.swiftSchemas.ResponseFunctionCallArgumentsDoneEventto the new top-levelResponseFunctionCallArgumentsDoneEvent.rawEventfallback.rawEvent.value19branch now bridges to the extracted type so the fallback path stays valid.Tests/OpenAITests/ResponseFunctionCallArgumentsDoneEventTests.swift— decode-with-name, decode-without-name, round-trip, and an end-to-end check throughResponseStreamEvent.More Info
.functionCallArguments(.done(let event))continues to compile (all the original fields are still present on the new type); only the static type ofeventchanges. Code that explicitly annotated the bound variable asComponents.Schemas.ResponseFunctionCallArgumentsDoneEventwould need to drop the annotation or switch to the new type.nameis modeled as optionalString?for forward-compat with servers that haven't shipped the field yet.swift buildclean; fullswift testis 183 passed / 0 failed (4 new tests for this event).🤖 Generated with Claude Code