fix: emit response.output_text.done streaming event per OpenAI spec#5308
fix: emit response.output_text.done streaming event per OpenAI spec#5308robinnarsinghranabhat wants to merge 2 commits intollamastack:mainfrom
Conversation
The LlamaStack server was missing the `response.output_text.done` streaming event, which the OpenAI Responses API spec requires between `output_text.delta` and `content_part.done`. This event carries the final accumulated text and logprobs. Discovered by comparing streaming event sequences between OpenAI's gpt-5.1 (ground truth) and LlamaStack server output using the OpenAI Python client. Changes: - streaming.py: Import and emit OutputTextDone with final text and logprobs before content_part.done - openai_responses.py: Add logprobs field to OutputTextDone type definition (required per OpenAI spec) - test_openai_responses.py: Verify output_text.done is emitted with correct fields and ordering (before content_part.done)
8b6ac1c to
f76c9c8
Compare
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ llama-stack-client-node studio · conflict
✅ llama-stack-client-openapi studio · code · diff
✅ llama-stack-client-go studio · conflict
✅ llama-stack-client-python studio · conflict
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
Summary
The LlamaStack server was missing the
response.output_text.donestreaming event, which the OpenAI Responses API spec requires betweenoutput_text.deltaevents andcontent_part.done.Discovered by comparing streaming event sequences between OpenAI's
gpt-5.1(ground truth) and LlamaStack server output using the OpenAI Python client.Fixes #5309
Changes
streaming.py: Import and emitOutputTextDonewith final accumulated text and logprobs, beforecontent_part.doneopenai_responses.py: Addlogprobsfield toOutputTextDonetype definition (per OpenAI spec)test_openai_responses.py: Verifyoutput_text.doneis emitted with correct fields and orderingTest plan
Reproduce with this snippet
Prerequisites: LlamaStack server running at
localhost:8321with a registered model.Ground truth (OpenAI
gpt-5.1directly)Before this PR
After this PR
Note: Reasoning streaming events are not fully spec-compliant yet (e.g. incorrect ordering, missing
output_item.added/donefor reasoning items). That will be addressed in a follow-up PR. This PR focuses solely on the missingoutput_text.doneevent.Unit tests: 223 passing (
uv run pytest tests/unit/providers/responses/builtin/ -q)