-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
Description
This is just my suggestion.
When I encountered an issue, I noticed that the ResponseReasoningSummaryPartDoneEvent event was returned together with the ResponseOutputItemDoneEvent. In fact, the reasoning stream had already ended much earlier. Would you consider immediately returning the ResponseOutputItemDoneEvent once there is no longer any reasoning_content being output? I understand that it may not be ideal to determine the end of the reasoning stream solely based on the reasoning_content field.
Current source code:
openai-agents-python/src/agents/models/chatcmpl_stream_handler.py
Lines 346 to 363 in f903ad0
| if state.reasoning_content_index_and_output: | |
| yield ResponseReasoningSummaryPartDoneEvent( | |
| item_id=FAKE_RESPONSES_ID, | |
| output_index=0, | |
| summary_index=0, | |
| part=DoneEventPart( | |
| text=state.reasoning_content_index_and_output[1].summary[0].text, | |
| type="summary_text", | |
| ), | |
| type="response.reasoning_summary_part.done", | |
| sequence_number=sequence_number.get_and_increment(), | |
| ) | |
| yield ResponseOutputItemDoneEvent( | |
| item=state.reasoning_content_index_and_output[1], | |
| output_index=0, | |
| type="response.output_item.done", | |
| sequence_number=sequence_number.get_and_increment(), | |
| ) |