Skip to content

fix(ai): support JSONL responses in Google-compatible streams - #3887

Open
Loxia106 wants to merge 1 commit into
Yeachan-Heo:devfrom
Loxia106:pr/google-ndjson-stream-fallback
Open

fix(ai): support JSONL responses in Google-compatible streams#3887
Loxia106 wants to merge 1 commit into
Yeachan-Heo:devfrom
Loxia106:pr/google-ndjson-stream-fallback

Conversation

@Loxia106

@Loxia106 Loxia106 commented Aug 5, 2026

Copy link
Copy Markdown

What

  • Select newline-delimited JSON parsing for explicit NDJSON and JSONL response media types.
  • Preserve SSE parsing and event callbacks for standard, missing, and unknown media types.
  • Add focused coverage for media-type normalization, unknown-type fallback, unterminated final records, malformed input, usage, finish state, and callback behavior.
  • Document the compatibility fix in the AI package changelog.

Why

Google-compatible streaming providers can return newline-delimited JSON while exposing the same streaming response schema. Treating those records as SSE drops valid chunks because they do not use SSE framing.

The parser selection is limited to an explicit media-type allowlist so unknown response types continue to use the existing SSE path.

Testing

  • bun test packages/ai/test/google-stream-content-type.test.ts packages/ai/test/google-safety-stop.test.ts — 12 passed, 0 failed, 93 assertions
  • bun --cwd=packages/ai run check — passed
  • git diff --check upstream/dev...HEAD — passed
  • CI=0 bun check — blocked by an unchanged upstream canonicalization self-test (expected exit 1, got 0); the focused tests and complete AI package check pass

GJC verdict

gajae.pr-review-verdict.v1 merge-approved sha256:ad54358911b14111ac42147464e0baf1c0569a119a44d32d28e42c6901475b03 reviewer:architect evidence:local-command:bun-test+packages-ai-check

  • Target branch is dev
  • bun check passes
  • Tested locally
  • CHANGELOG updated (if user-facing)
  • Verdict above matches the exact PR head, not an earlier commit

@Loxia106
Loxia106 force-pushed the pr/google-ndjson-stream-fallback branch from f22a51b to bc9167f Compare August 6, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant