Skip to content

server: fix SSE and OpenAI compatibility for error messages when streaming#16109

Merged
ngxson merged 2 commits into
ggml-org:masterfrom
BenjaminBruenau:fix/server/sse-spec-error-messages-compatibility
Sep 20, 2025
Merged

server: fix SSE and OpenAI compatibility for error messages when streaming#16109
ngxson merged 2 commits into
ggml-org:masterfrom
BenjaminBruenau:fix/server/sse-spec-error-messages-compatibility

Conversation

@BenjaminBruenau

Copy link
Copy Markdown
Contributor

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

Comment thread tools/server/server.cpp Outdated
}
}, [&](const json & error_data) {
server_sent_event(sink, "error", error_data);
server_sent_event(sink, "data", json{{"error", error_data}});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we no longer need the second argument of server_sent_event, as it will always be "data"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: {....}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ngxson commented Sep 20, 2025

Copy link
Copy Markdown
Collaborator

cc @allozaur you may need to update web ui code too (not urgent)

@ngxson ngxson merged commit 459c0c2 into ggml-org:master Sep 20, 2025
54 of 55 checks passed
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
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…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
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…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
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…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
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…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
phibya pushed a commit to ziee-ai/llama.cpp that referenced this pull request May 29, 2026
…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
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request May 30, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants