fix: handle missing tool identity in OpenAI Native streams #10719
+114
−9
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
Some OpenAI-compatible providers (streaming via Responses API or similar) emit
tool_call_arguments.deltaevents without repeating thecall_idornamethat was provided in the initialoutput_item.added(oroutput_item.doneif it arrived earlier). This caused theOpenAiNativeHandlerto emit partial tool call chunks with undefined ID/name, which the downstream parser ignored or failed to handle correctly.This change ensures that we capture the tool identity from
output_itemevents and use it as a fallback for subsequent argument deltas that lack identity.Changes
pendingToolCallIdandpendingToolCallNametoOpenAiNativeHandlerstate.processEventto capture tool identity fromresponse.output_item.addedandresponse.output_item.doneevents.processEventto use the pending identity when processingresponse.tool_call_arguments.deltaorresponse.function_call_arguments.deltaif the event itself is missing the ID/name.src/api/providers/__tests__/openai-native-tools.spec.ts.Important
Fixes missing tool identity handling in
OpenAiNativeHandlerby using pending identifiers from initial events as fallbacks.OpenAiNativeHandlerwheretool_call_arguments.deltaevents withoutcall_idornamewere ignored by capturing tool identity fromoutput_item.addedandoutput_item.doneevents.pendingToolCallIdandpendingToolCallNameas fallbacks for missing identifiers in subsequent events.pendingToolCallIdandpendingToolCallNametoOpenAiNativeHandlerto track last observed tool identity.openai-native-tools.spec.tsto verify handling of missing identifiers intool_call_arguments.deltaevents.This description was created by
for 270a446. You can customize this summary. It will automatically update as commits are pushed.