Repository navigation
fix(providers): fail a stream whose body contains no provider events - #322
Merged
nathanschmid08 merged 1 commit intoNov 13, 2026
Merged
Conversation
Contributor
|
Hi @nova-loop , Thanks for the PR. I appreciate it very much. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A streaming completion whose body contains no parseable provider events now fails with
ProviderUnavailableError(PROVIDER_UNAVAILABLE). It no longer ends as an emptycompleteturn. This follows the issue's suggested fix, applied to all four adapters:sawAnyEventflag. The SSE parser (parseSseData/parseSseEvent/parseSseChunk) gets one extraonParsedcallback, which it calls right after a payload parses as JSON. The missing-sentinel fallback still yieldscompletewhen at least one event was parsed. When none was, it throwsProviderUnavailableError('<Provider> returned no stream events').On the two decisions the issue raised:
ProviderUnavailableErroris aModelAdapterError, so it goes through the existing catch in each adapter unchanged, andstreamMemberTurn's existing error handling (from No usage event is recorded when a completion fails or is cancelled after the provider has already produced output #302) runs. I did not touch the chat/service layer.Why
Closes #315
When a proxy or maintenance page answered
200 text/html, you got a 502 on the non-streaming path but a silent empty assistant turn on the streaming path. That empty turn was then replayed as context.How it was tested
ProviderUnavailableError/PROVIDER_UNAVAILABLEand a "no stream events" messagecompletenpx vitest runinapps/api: 119 files, 1909 tests pass. The e2e config (vitest.config.e2e.ts): 25 files, 822 tests pass.npm run lint -w @glassbeetle/api(oxlint): clean.tsc -p tsconfig.build.json --noEmit: clean.openai.adapter.spec.tspassesprettier --check. The other six touched files already fail it onmain(The format check has never run in CI, and 92 committed files no longer pass it #246). I didn't reformat them, to keep the diff focused.Anything left out, or worth a second opinion
Content-Type: text/event-streamcheck the issue mentions as an extra guard. As the issue says, it can't be the only guard, and some OpenAI-compatible servers label streams loosely. The parsed-event flag covers both the HTML case and the empty-body case, so I kept this PR to that. I'm happy to add the header check as a follow-up if you'd like it.Checklist
npm run lint -w @glassbeetle/apipasses (API changes)npm testpasses (API unit + e2e suites; see above)npm run buildpasses (only the APItscbuild was run)AI assistance
This change was prepared with AI assistance. An AI coding assistant wrote the code and tests from the issue. I reviewed the diff and ran the checks listed above before opening the PR.