mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-27 16:07:02 +00:00
A terminal event that arrives with an empty output was rebuilt from delta accumulation. BufferedResponseAccumulator models only one reasoning item, one message, and N function calls, and records no item id, status, or phase, so a turn carrying several items collapsed into a single fabricated message: the reasoning item disappeared, the real message id was replaced, and phase was lost. reconstructResponseOutputFromSSE already prefers the raw output_item.done items over accumulation for buffered responses. The streaming path had no equivalent because it never sees the whole body at once. Collect the raw item of each output_item.done keyed by output_index and rebuild from those, falling back to accumulation only when the stream reported no done item at all. Items are stored as raw JSON, so vendor extensions and item types this gateway does not model survive the rebuild verbatim. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>