Repository navigation
Description
Bug
When using the OpenAI Responses API streaming path (gpt-4.1 via type: openai), tool call arguments are not being fully accumulated from response.function_call_arguments.delta events. The resulting tool calls have args: null (empty/partial JSON), causing the tool validator to fail with EOF.
Evidence
Running a single-turn scenario where the model should call lookup_order(order_id: "1023"):
{
"role": "assistant",
"tool_calls": [
{
"id": "call_rUoQolYZYjHXo1k6jxeAgT2V",
"name": "lookup_order",
"args": null
}
]
}The model correctly identifies the tool to call (3 consecutive attempts), but args are always null. The tool validator then fails:
Error: validation error for tool lookup_order: EOF
The model retries 3 times, gets the same EOF error each time, then gives up and responds without tool data.
Root cause analysis
In runtime/providers/openai/openai_responses_integration.go:
-
handleOutputAdded(line 799-802) creates the tool call withArgs: json.RawMessage("")and maps bothitem.Item.IDanditem.Item.CallIDto the tool call index inidMap. -
handleFuncArgsDelta(line 741-778) looks up the tool call index viadelta.ItemIDordelta.CallIDin theidMap. -
Suspected issue: The ID used in
response.function_call_arguments.deltaevents doesn't match either ID stored inidMapfrom theresponse.output_item.addedevent. This causes theidx < 0check at line 768 to skip the argument accumulation entirely.The output JSON shows
"id": "call_rUoQolYZYjHXo1k6jxeAgT2V"(Chat Completions format), but the Responses API typically usesfc_prefixed IDs.transformToResponsesCallIDexists for outbound ID conversion, but the inbound delta events may use a different ID field or format than whathandleOutputAddedstored. -
Result: Args stay as
json.RawMessage("")(len 0), get replaced with{}in the validator, but if any partial delta DID land (e.g., just{), the incomplete JSON causes the schema validator to fail with EOF rather than a missing-field error.
Reproduction
promptarena run \
-c acme-apparel-support/config.arena.yaml \
--scenario smoke-test-single-turn \
--provider openai-direct \
-vWhere openai-direct is type: openai, model: gpt-4.1, base_url: https://api.openai.com/v1.
The scenario sends: "Hi, my order #1023 still hasn't arrived..." — the model calls lookup_order but args are empty.
Suggested investigation
- Add debug logging in
handleFuncArgsDeltato printdelta.ItemID,delta.CallID, and the currentidMapcontents — this will show whether the lookup is failing - Check whether the Responses API
function_call_arguments.deltaevents useitem_id(matchingoutput_item.added.item.id) orcall_id(matchingoutput_item.added.item.call_id) — the code checks both but the actual API may use a field not being captured - The capability matrix tests may not cover this path if they use Chat Completions or non-streaming
Version
promptarena version dev
Activity
chaholl commentedon Apr 12, 2026
Investigation findings
Tested the
handleOutputAddedandhandleFuncArgsDeltahandlers in isolation — they work correctly. The ID matching logic is sound:handleOutputAddedstoresitem.id(e.g.,fc_abc123) anditem.call_id(e.g.,call_xyz789) inidMaphandleFuncArgsDeltalooks updelta.item_idthen falls back todelta.call_idinidMapitem_idandcall_idlookup paths, including the no-match caseAlso wrote an end-to-end test (
TestStreamResponsesResponse_ToolCallAccumulation) that simulates a full SSE stream withoutput_item.added→ twofunction_call_arguments.deltaevents →completed— args accumulate correctly to{"order_id":"1023"}.What this rules out:
What this doesn't rule out (and where to look next):
SSE framing issue — if the real OpenAI API sends multi-line
data:fields or uses chunked transfer encoding that splits a JSON payload across multiplescanner.Scan()reads, the current line-by-line SSE parser would silently skip the partial lines. ThestreamResponsesResponsefunction at line 909 requires each SSE event to be a single line starting withdata:.response.function_call_arguments.doneevent — the code has no handler for this event type. If the API sends adoneevent with the complete arguments (which it does per OpenAI docs), this could be a safety net. Adding a handler forresponse.function_call_arguments.donethat sets the full args fromitem.argumentsin the completed response would make the accumulation resilient to missed deltas.Event ordering / race — if
function_call_arguments.deltaarrives beforeoutput_item.added(unlikely but possible with SSE),idMapwould be empty and the delta would be silently dropped. No logging exists for this case.Recommended next steps:
handleFuncArgsDeltawhenidx < 0(ID lookup fails) — this will prove or disprove the ID mismatch theory in productionresponse.function_call_arguments.doneas a safety netThe tests I wrote are on
feat/azure-openai-platform(not yet merged) — will include them in the PR or split out.fix(providers): accumulate Responses API tool args via output_index f…
fix(providers): accumulate Responses API tool args via output_index f…
feat(evals): add require_args param to tools_called assertion (#943)
feat(evals): add require_args param to tools_called assertion (#943) (#…