feat: Populate name field in ResponseFunctionCallArgumentsDoneEvent from snapshot#2731
+27 −1
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.
Problem
When using Responses API streaming with multiple function tools, the
response.function_call_arguments.doneevent returnsname=None, making it impossible to determine which function to call.Example from issue #2723:
This breaks multi-tool scenarios where the application needs to know which function was called to route the execution correctly.
Root Cause
ResponseStreamState.handle_event()only processes delta events for function calls, not done events:The raw event from the API doesn't include the
namefield - it must be taken from the accumulated snapshot.Solution
Added
elifblock to handleresponse.function_call_arguments.doneevents, following the proven pattern from Chat Completions API's_add_tool_done_event()method.Changes:
ResponseFunctionCallArgumentsDoneEventimportparse_function_tool_argumentsimportnamefrom accumulated snapshot (not raw event)parsed_argumentsusing input_toolsResponseFunctionCallArgumentsDoneEventin__init__.pyAfter fix:
Pattern
This follows the same approach as Chat Completions streaming (
src/openai/lib/streaming/chat/_completions.py:708-731), which correctly emits done events with name from the snapshot.Impact
Non-breaking change:
NoneRelated Issues
Example Usage
Before:
After:
Files Changed
src/openai/lib/streaming/responses/_responses.py: Added elif block + imports (24 lines)src/openai/lib/streaming/responses/__init__.py: Exported done event (1 line)Testing
The fix follows the proven pattern from Chat Completions, which has been working correctly for months. The type
ResponseFunctionCallArgumentsDoneEventalready has thenamefield defined, and the snapshotParsedResponseFunctionToolCallcontains the name - this change simply connects them.