mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 23:02:10 +03:00
When an upstream provider sends a batched response.completed event carrying function_call items in its data.response.output[] array — without having sent the individual response.output_item.added / .delta / .done events — the state variables toolCallIndex and currentToolCallId were never set, causing computeFinishReason to return 'stop' instead of 'tool_calls'. This broke the agent loop for downstream Chat Completions clients (OpenCode, Hermes, etc.) when routing through providers that batch their output into the completed event. Fix: parse data.response.output[] for function_call items in the response.completed handler, synthesize the tool call header + arguments delta chunks, advance state, and emit finish_reason: 'tool_calls'. Also updates withAssistantRoleOnFirstDelta to handle array results. Fixes #180, #3980 Refs: https://github.com/diegosouzapw/OmniRoute/issues/180 Refs: https://github.com/diegosouzapw/OmniRoute/issues/3980