Skip to content

Fix SDK 0.16 stream completion at DONE (LAN-873) - #92

Merged
Thyrst merged 5 commits into
v0.16.xfrom
lan-873-stream-completion
Oct 27, 2026
Merged

Thyrst merged 5 commits into
v0.16.xfrom
lan-873-stream-completion

Conversation

@Thyrst

@Thyrst Thyrst commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

A complete tool response can remain pending after the server sends [DONE] if the HTTP connection stays open. Finish the SDK stream at that terminal SSE event and cancel the response body without waiting for cancellation to settle. Keep reading past finish_reason so later token usage is preserved.

Bumps the package to 0.16.22 and adds its changelog entry. Publishing will follow review and is not performed by this PR.

Addresses LAN-873 for SDK 0.16.x / Vercel AI SDK 4, the compatibility line used by Macaly. The equivalent SDK 1.x / AI SDK 5 fix is PR #93, targeting main.

  • Add bounded SSE framing detection covering split chunks, LF/CR/CRLF, a split leading UTF-8 BOM, Unicode, false markers, source errors and caller cancellation.
  • Add real HTTP regressions for completed tools/usage with an open connection, structured provider errors and caller abort.
  • Upgrade test-only Nock to 14.0.17 to support response cancellation; adapt header assertions and put the existing live proxy test behind the repository's TEST_LIVE flag. Runtime dependencies are unchanged.

Validation: all 193 offline tests pass on Node 18.20.8, 20.20.2 and 24.14.1 (nine live tests skipped per run). TypeScript, build/declarations, ESM/CommonJS loading, formatting and diff checks pass. Three real-HTTP completion regressions fail against the base implementation and pass with the fix. Expanded coverage includes ten active cancellation races, pre-header/silent/partial-event cancellation, socket resets, parallel tools, signed reasoning, delayed/zero usage and 200 randomized SSE layouts. The split-BOM regression failed before the additional framing correction.

Macaly's exact patched AI SDK 4.3.16/provider-utils 2.2.6 combination passes all 94 bridge tests. Built SDK artifacts were exercised against six staging provider routes, including native Anthropic/Google, OpenRouter and Bedrock Sonnet/Opus: text, tool continuation, non-streaming generation, client cancellation and invalid-model errors pass for both SDK versions. Across both versions and structured-output reruns, 98 HTTP requests have 98 matching saved logs. Five corrected structured-output cases failed; replaying all 24 structured-output responses through base and patched SDKs produced identical results. Existing native-Gemini usage and hosted upstream-cancellation limitations remain.

Publishing a 0.16 patch and updating Macaly remain separate release steps. This does not add deadlines, repair missing terminal bytes, or implement LAN-875.

CI now runs on PRs targeting v0.16.x as well as main. Live generation tests explicitly use gpt-6-luna, overriding the deployed fixtures' retired model. CI passed on c8114a3: all 202 tests, including the live tests, plus TypeScript, package build and CommonJS/ESM conversion checks.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T11:32:09.017554Z 6ffe9fe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Thyrst
Thyrst merged commit 37b2a97 into v0.16.x Oct 27, 2026
2 checks passed
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