server: fix SSE and OpenAI compatibility for error messages when streaming#16109
Merged
ngxson merged 2 commits intoggml-org:masterfrom Sep 20, 2025
Conversation
ngxson
reviewed
Sep 19, 2025
| } | ||
| }, [&](const json & error_data) { | ||
| server_sent_event(sink, "error", error_data); | ||
| server_sent_event(sink, "data", json{{"error", error_data}}); |
Contributor
There was a problem hiding this comment.
Seems like we no longer need the second argument of server_sent_event, as it will always be "data"
Contributor
Author
There was a problem hiding this comment.
Yeah that makes sense.
Should this be kept in a way to make it compatible with the actual event field of the SSE spec (in a line above the data - if specified) or should that parameter be completely removed and simply always only use the data line?
e.g.
event: error
data: {error: {....}}
Contributor
There was a problem hiding this comment.
I think most parsers will accept format data: {error: {....}}, anything outside of that always caused problems for downstream in the past, like the data: [DONE] for example.
ngxson
approved these changes
Sep 20, 2025
Contributor
|
cc @allozaur you may need to update web ui code too (not urgent) |
struct
pushed a commit
to struct/llama.cpp
that referenced
this pull request
Sep 26, 2025
…aming (ggml-org#16109) * server: fix SSE and OpenAI compatibility for error messages when streaming * server: remove obsolete event parameter and use required data fieldname instead
pwilkin
pushed a commit
to pwilkin/llama.cpp
that referenced
this pull request
Oct 23, 2025
…aming (ggml-org#16109) * server: fix SSE and OpenAI compatibility for error messages when streaming * server: remove obsolete event parameter and use required data fieldname instead
blime4
referenced
this pull request
in blime4/llama.cpp
Feb 5, 2026
…aming (#16109) * server: fix SSE and OpenAI compatibility for error messages when streaming * server: remove obsolete event parameter and use required data fieldname instead
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.
This fixes compatibility with the SSE specification by not sending error messages out with an incompatible fieldname.
Therefore this also ensures proper exceptions when working for example with OpenAI client libraries, instead of being handled as an empty message.
Closes:
#16104