Fix delta key in last streaming response in case there is empty content#4372
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenAI Chat Completions streaming output to always include a delta object in each streamed choices[] entry, including the final “finish_reason-only” chunk when the parser returns an empty document (e.g., when generation ends on a swallowed token). This aligns OVMS streaming output with the expected OpenAI-compatible schema and adds a regression test to prevent future regressions.
Changes:
- Ensure
serializeStreamingChunk()emits"delta": {}when the parsed streaming delta document has no"delta"member. - Add a unit test covering the empty-document final chunk case, asserting both presence of
"delta":{}and correctfinish_reasonserialization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/llm/apis/openai_completions.cpp |
Adds fallback emission of an empty delta object when the parser provides no delta for a streaming chunk. |
src/test/http_openai_handler_test.cpp |
Adds a regression test asserting that the streaming chunk always contains a delta field even when the parsed delta is empty. |
mzegla
approved these changes
Jul 16, 2026
dtrawins
approved these changes
Jul 16, 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.
No description provided.