diff --git a/src/agents/models/chatcmpl_stream_handler.py b/src/agents/models/chatcmpl_stream_handler.py index 474bffe09..5faf06c14 100644 --- a/src/agents/models/chatcmpl_stream_handler.py +++ b/src/agents/models/chatcmpl_stream_handler.py @@ -150,6 +150,12 @@ async def handle_stream( ) if reasoning_content and state.reasoning_content_index_and_output: + # Ensure summary list has at least one element + if not state.reasoning_content_index_and_output[1].summary: + state.reasoning_content_index_and_output[1].summary = [ + Summary(text="", type="summary_text") + ] + yield ResponseReasoningSummaryTextDeltaEvent( delta=reasoning_content, item_id=FAKE_RESPONSES_ID, @@ -201,7 +207,7 @@ async def handle_stream( ) # Create a new summary with updated text - if state.reasoning_content_index_and_output[1].content is None: + if not state.reasoning_content_index_and_output[1].content: state.reasoning_content_index_and_output[1].content = [ Content(text="", type="reasoning_text") ]