[Platform][OpenAi] Route commentary phase to ThinkingDelta in streaming responses#2006
Open
Amoifr wants to merge 1 commit intosymfony:mainfrom
Open
[Platform][OpenAi] Route commentary phase to ThinkingDelta in streaming responses#2006Amoifr wants to merge 1 commit intosymfony:mainfrom
Amoifr wants to merge 1 commit intosymfony:mainfrom
Conversation
…ng responses The OpenAI Responses API emits both `commentary` and `final_answer` as `response.output_text.delta` events. The previous `str_contains($type, 'output_text')` guard treated them identically, causing the visible assistant text to be duplicated whenever the model produced a commentary that mirrored the final answer. Phases are now tracked per `item_id` via `response.output_item.added`, and `response.output_text.delta` is routed accordingly: * commentary → ThinkingStart / ThinkingDelta, finalized by ThinkingComplete on `response.output_item.done` * final_answer / unknown phase / missing `item_id` → TextDelta (backward compatible with the previous behavior) The reasoning_summary_text.* path now uses its own buffer to avoid colliding with commentary tracking. Closes symfony#1979
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.
The OpenAI Responses streaming API emits both
commentaryandfinal_answerasresponse.output_text.deltaevents. The currentstr_contains($type, 'output_text')guard inGpt\ResultConverter::convertStream()treats them identically, so the visible assistant text gets duplicated whenever the model emits a commentary that mirrors the final answer (the bug reported by @wimwinterberg).Phases are now tracked per
item_idviaresponse.output_item.added, andresponse.output_text.deltais routed accordingly:commentary→ThinkingStart/ThinkingDelta, finalized byThinkingCompleteonresponse.output_item.donefinal_answer/ unknown phase / missingitem_id→TextDelta(backward compatible)The
response.reasoning_summary_text.*path now uses its own buffer ($currentReasoningSummary) to avoid colliding with the commentary buffer.The fix follows the approach @wimwinterberg sketched in the issue thread; this PR formalizes it and adds an exhaustive test suite (9 tests) covering:
item_idkeeps its TextDelta (backward compat)item_id)response.output_item.donenever arrives)Thanks @OskarStark for the nudge on the issue.