Skip to content

fix(providers): Responses API tool call args dropped when delta uses output_index - #942

Merged
chaholl merged 1 commit into
mainfrom
fix/940-responses-api-tool-args
Apr 12, 2026
Merged

chaholl merged 1 commit into
mainfrom
fix/940-responses-api-tool-args

Conversation

@chaholl

@chaholl chaholl commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix tool call arguments silently dropped during OpenAI Responses API streaming when delta events use output_index instead of item_id/call_id
  • Add output_index as a third fallback key in the delta-to-tool-call mapping

Root Cause

handleFuncArgsDelta matched delta events to tool calls using only item_id and call_id. The OpenAI Responses API can send response.function_call_arguments.delta events with only output_index — when this happens, the ID lookup fails silently, args stay as json.RawMessage("") (serializes to null), and the tool validator fails with EOF.

Fix

  • handleOutputAdded now stores output_index (as "idx:N") in the idMap alongside item.id and item.call_id
  • handleFuncArgsDelta falls back to output_index when both item_id and call_id lookups miss

Test plan

  • TestHandleFuncArgsDelta_OutputIndexOnly — reproduces the exact openai responses API: tool call arguments not accumulated during streaming #940 failure: delta with only output_index, no item_id/call_id
  • TestHandleFuncArgsDelta_IDMatching — verifies all three ID types are stored in idMap
  • TestHandleFuncArgsDelta_CallIDFallback — call_id-only delta
  • TestStreamResponsesResponse_ToolCallAccumulation — end-to-end SSE stream with full tool call lifecycle

Closes #940

…allback (#940)

The handleFuncArgsDelta handler only matched delta events by item_id
or call_id. When the OpenAI Responses API sends delta events with
only output_index (no item_id/call_id), the lookup silently failed
and tool call arguments stayed empty — causing the tool validator
to fail with EOF.

Fix: handleOutputAdded now also stores output_index in the idMap,
and handleFuncArgsDelta falls back to output_index when item_id
and call_id lookups both miss.

Closes #940
@sonarqubecloud

Copy link
Copy Markdown

@chaholl
chaholl merged commit 1fb7c66 into main Apr 12, 2026
22 checks passed
@chaholl
chaholl deleted the fix/940-responses-api-tool-args branch April 12, 2026 12:14
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.

openai responses API: tool call arguments not accumulated during streaming

1 participant