fix: OpenAI Responses streams silently dropping schema-invalid known events and reporting stop (#19495)
## Background Schema-invalid OpenAI Responses events could silently discard completed tool calls and make an invalid stream appear to have completed successfully. ## Root Cause The permissive unknown-event fallback converted malformed known events into ignored chunks, including malformed output-item envelopes and an unmodeled function-call-arguments completion event, while response.completed could overwrite the resulting error finish reason with stop. ## Summary Known malformed Responses events now emit stream errors, response.function_call_arguments.done is validated, malformed output-item envelopes cannot enter the unknown fallback, error finish reasons are preserved, genuinely future event and item types remain ignored, and the existing patch changeset covers the behavior. ## Testing Regression coverage verifies malformed known events, output-item envelope variants, valid and malformed function-call-arguments completion events, error finish preservation, and forward compatibility for unknown event and item types. OpenAI package tests, AI package Node and Edge tests, the full workspace suite, lint, formatting, and full type checking pass. ## End-to-end Validation - `pnpm -C examples/ai-functions exec tsx -e '<Responses stream replay>'` produced one tool call with `tool-calls` for the valid control and four errors with an `error` finish reason for the schema-invalid stream. ## Related Issues Fixes #19493 Closes #19494 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: Sparky579 <48359461+Sparky579@users.noreply.github.com> Co-authored-by: ai-sdk-factory[bot] <305873210+ai-sdk-factory[bot]@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
eee620060bd703f3e7cd34dbe2a2ced853e6283d
Parent: 309ba00
Committed by GitHub <noreply@github.com>
on 8/25/2026, 4:40:28 PM