Skip to content

Fix delta key in last streaming response in case there is empty content#4372

Merged
dkalinowski merged 3 commits into
mainfrom
fix-delta
Jul 16, 2026
Merged

Fix delta key in last streaming response in case there is empty content#4372
dkalinowski merged 3 commits into
mainfrom
fix-delta

Conversation

@dkalinowski

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 correct finish_reason serialization.

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.

@dkalinowski dkalinowski added this to the 2026.3 milestone Jul 16, 2026
@dkalinowski
dkalinowski merged commit 5fe31f2 into main Jul 16, 2026
1 check passed
@dkalinowski
dkalinowski deleted the fix-delta branch July 16, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants