Repository navigation
fix(server): emit error message on streaming failure before [DONE] - #2888
Merged
inureyes merged 2 commits intoNov 9, 2026
Merged
Conversation
Streaming chat completions reported a failure only as a bare
finish_reason "error" and dropped the underlying message, leaving
clients without a diagnosis. When the stream is already open, the
failure now travels as an in-stream error object:
data: {"error":{"message":"...","type":"server_error","code":null}}
followed by the existing finish_reason "error" chunk and [DONE].
Known-before-first-token failures still return a non-2xx response on
the non-streaming path.
Closes lablup#2877
Report a streaming generation failure through the same classification as the non-streaming path, so a worker-gone or over-context failure keeps its sanitized wording and error type instead of a raw `server_error` string. Emit the error object before the `finish_reason: "error"` chunk on chat as well as completions, as issue lablup#2877 specifies, and keep `finish_reason` as `error` when a failed generation's partial output parsed as a tool call. Refuse a text prompt longer than the per-slot context on the dispatch thread, before SSE headers, against the bound the scheduler publishes. A streaming request now gets the same 400 `exceed_context_size_error` as the non-streaming path. Add route tests for the event order, the classification, the tool-call case and the pre-header refusal.
Member
|
Hardening review, pushed as Findings fixed
Security and performance: no new input surface. Validation on GB10: 3904 |
This was referenced Nov 9, 2026
This was referenced Nov 9, 2026
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.
Summary
Streaming chat completions (
/v1/chat/completionsand/v1/completions) reported a failure only as a barefinish_reason: "error"and dropped the underlying error message entirely. Clients that consume the SSE stream receivedata: [DONE]with no diagnosis of what went wrong.This PR keeps the stream open after a generation failure and emits the failure as an in-stream error object before the terminator:
Failures known before the first token still return a non-2xx response matching the non-streaming path (unchanged).
Changes
src/server/routes/chat.rs— extract the failure message from theErrvariant of the generation result; when non-empty, send an in-streamerrorobject viafinish_events.json(...)beforefinish_events.done(); retain the existingfinish_reason: "error"chunk.src/server/routes/completions.rs— same fix for the/v1/completionsstreaming path.Test plan
cargo build --release --features accelerate(Metal backend is unavailable on this host; the fix is server-route code and does not touch kernels)cargo clippy --release --features accelerate -- -D warningscargo fmt --checkCloses #2877