Repository navigation
feat(openai): option to send the Responses message phase when the item starts - #8429
Draft
cchen-dialpad wants to merge 1 commit into
Draft
cchen-dialpad wants to merge 1 commit into
cchen-dialpad wants to merge 1 commit into
Conversation
…m starts The Responses API sets an output message's phase (commentary or final_answer) on response.output_item.added, but the engine ignored that event and sent the phase only from response.output_item.done, after the message's text. A caller that speaks only the final_answer had to buffer each message until it ended. openai.responses.LLM(emit_phase_on_item_start=True) sends the phase chunk when the message starts, before its text, and does not repeat it when the message ends. If the start event carries no phase, it is still sent at the end. The default (False) keeps the current behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Contributor
|
related to #8427 |
This branch has not been deployed
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.
Summary
The OpenAI Responses API sets an output message's
phase(commentaryorfinal_answer) onresponse.output_item.added.ResponsesLLMStreamignores that event and sends the phase only fromresponse.output_item.done, after the message's text. An agent that speaks only thefinal_answertherefore has to buffer each message until it ends.This PR adds an opt-in setting,
openai.responses.LLM(emit_phase_on_item_start=True):delta.extra == {"openai": {"phase": ...}}) is sent when the message starts, before its text, and isn't repeated when it ends.False), behaviour is unchanged:output_item.addedis still ignored on both WebSocket and HTTP.ResponsesLLMStreamtakes a matching optional argument with the same default, soinference.responses.LLMand the Azure, xAI and Perplexity subclasses are unaffected.Usage
Tests
New hermetic tests in
tests/test_plugin_openai_responses.py, run over both WebSocket and HTTP:False, the phase arrives after the text.True, each phase arrives once, before its text.Truebut no phase on the start event, the phase arrives after the text.make checkandpytest --plugin openai tests/test_plugin_openai_responses.pypass.🤖 Generated with Claude Code