Skip to content

Bug: Add missing name field to ResponseFunctionCallArgumentsDoneEvent#420

Merged
nezhyborets merged 1 commit into
mainfrom
claude/issue-409-function-call-args-done-name
May 18, 2026
Merged

Bug: Add missing name field to ResponseFunctionCallArgumentsDoneEvent#420
nezhyborets merged 1 commit into
mainfrom
claude/issue-409-function-call-args-done-name

Conversation

@Krivoblotsky
Copy link
Copy Markdown
Contributor

What

The response.function_call_arguments.done streaming event is documented by OpenAI as carrying a name field 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.ResponseFunctionCallArgumentsDoneEvent is missing it (the upstream OpenAPI spec lags), so SDK users couldn't read the function name from this event.

This PR:

  • Extracts the type to Sources/OpenAI/Public/Schemas/Edited/ResponseFunctionCallArgumentsDoneEvent.swift with a new public var name: Swift.String? field, following the documented pattern in CONTRIBUTING.md ("Extracting a generated Type") and the existing precedent for ResponseMCPCallArgumentsDoneEvent.
  • Updates the ResponseStreamEvent facade so .functionCallArguments(.done(_)) carries the extracted type. Adds an early decode block (mirroring the MCP one) so JSON with name round-trips correctly. Preserves the existing rawEvent.value19 fallback by converting from the generated type to the new one (with name: 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 surrounding output_item.added event, which is brittle.

Affected Areas

  • New file: Sources/OpenAI/Public/Schemas/Edited/ResponseFunctionCallArgumentsDoneEvent.swift
  • Modified: Sources/OpenAI/Public/Schemas/Facade/ResponseStreamEvent.swift
    • Enum case type changed from Schemas.ResponseFunctionCallArgumentsDoneEvent to the new top-level ResponseFunctionCallArgumentsDoneEvent.
    • Added an early-decode block before the rawEvent fallback.
    • The rawEvent.value19 branch now bridges to the extracted type so the fallback path stays valid.
  • New tests: Tests/OpenAITests/ResponseFunctionCallArgumentsDoneEventTests.swift — decode-with-name, decode-without-name, round-trip, and an end-to-end check through ResponseStreamEvent.

More Info

  • Source-compat note: pattern-matched code using .functionCallArguments(.done(let event)) continues to compile (all the original fields are still present on the new type); only the static type of event changes. Code that explicitly annotated the bound variable as Components.Schemas.ResponseFunctionCallArgumentsDoneEvent would need to drop the annotation or switch to the new type.
  • name is modeled as optional String? for forward-compat with servers that haven't shipped the field yet.
  • Local: swift build clean; full swift test is 183 passed / 0 failed (4 new tests for this event).

🤖 Generated with Claude Code

…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 nezhyborets merged commit b3fc100 into main May 18, 2026
3 checks passed
@nezhyborets nezhyborets deleted the claude/issue-409-function-call-args-done-name branch May 18, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResponseFunctionCallArgumentsDoneEvent event missing name field

2 participants