Skip to content

fix(server): align OpenAI completion response shapes - #1213

Open
Allegro-ma-non-troppo wants to merge 2 commits into
mainfrom
guohaotian/wp-01-sse-response-shape
Open

Allegro-ma-non-troppo wants to merge 2 commits into
mainfrom
guohaotian/wp-01-sse-response-shape

Conversation

@Allegro-ma-non-troppo

Copy link
Copy Markdown
Collaborator

Why. WP-01 fixes two SDK failures. Repeating delta.role corrupts the assembled assistant message, and the legacy completion finish choice lacked text and index.

What changed. Send the Chat role once and supply an opener for an empty successful stream. Use endpoint-specific IDs in both modes and a full legacy finish choice. Route generation failures to the existing error writers. A failed Chat turn does not flush text still buffered by the parser. Responses, Ollama, and reasoning-token accounting are unchanged.

Wire field Reference and result
Chat delta.role OpenAI Python accumulation and vLLM first-delta convention: one assistant role.
IDs and legacy finish choice vLLM prefixes and SDK choice fields: chatcmpl- and cmpl-, and text, index, logprobs, finish_reason on the finish choice.
Cancellation and faults SDK finish-reason literals: cancellation finishes as stop if sent; generation faults use existing error writers.

Tests and acceptance. On Windows NPU, the response-shape suite went from 0 passed and 6 failed on qwen3:0.6b to 6 passed and 0 failed, with 4 capability skips in both runs. On the PR head, qwen3.5:4b passed 7 shape checks with 3 OGA skips, both usage modes, and 12 Responses checks. A scripted engine passed all six handler failure and Responses control cases. The Windows Release build and strict host protocol checks passed. Pi completed the tool-result round trip 3/3 on both the base and the first fix commit. The request reference documents the new shape.

Not verified. Linux, HRX, OGA runtime, live reference endpoints, or physical cancellation and device faults.

WP corrections and follow-ups. The Chat writer moved into protocol_openai_chat.hpp in WP-37. WP-00 was waived; upstream suites replace its xfails. Real reasoning-token accounting is separate, and cancelled non-streaming prefill still belongs to WP-46.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

This branch is waiting to be deployed

1 waiting deployment
npu-approval — c3fc4029 Waiting Dec 1, 2026 by Allegro-ma-non-troppo via npu-approve #868
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.

1 participant