[Bugfix][Responses API] Build streamed final response from streamed items (#59307)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-09-30 00:16:05 +00:00
committed by GitHub
parent 4e0a414c44
commit 7ca31ef599
5 changed files with 151 additions and 75 deletions
@@ -126,6 +126,11 @@ def _validate_event_pairing(events: list, pairs_of_event_types: dict[str, str])
etype = event.type
if etype in end_events:
expected_start = pairs_of_event_types[etype]
# Deltas are optional, e.g. a function call with no arguments.
if expected_start.endswith(".delta") and (
not stack or stack[-1] != expected_start
):
continue
assert stack and stack[-1] == expected_start, (
f"Stack mismatch for {etype}: "
f"expected {expected_start}, "