Please read this first
Describe the bug
The Chat Completions streaming handler sometimes passes a boolean value as output_index for assistant message events after a reasoning item has been emitted.
Several event constructors use this expression:
output_index=state.reasoning_content_index_and_output is not None
When reasoning content exists, this produces True rather than the integer 1. Python treats bool as a subclass of int, so this can pass local numeric checks, but downstream JSON consumers and event snapshots can observe the wrong type.
Relevant code:
src/agents/models/chatcmpl_stream_handler.py: text, refusal, content-part-done, and output-item-done events use the boolean expression above.
Debug information
- Agents SDK version: current
main at 3854c124
- Python version: Python 3.12.1
Repro steps
Stream Chat Completions chunks where reasoning content is emitted before regular text content. Inspect the output_index on the text/message events that follow the reasoning item.
Current behavior: some events use True as output_index.
Expected behavior
All streamed response events should use integer output_index values, for example 0 for the reasoning item and 1 for the assistant message that follows it. No event should expose a boolean output_index.
Please read this first
Describe the bug
The Chat Completions streaming handler sometimes passes a boolean value as
output_indexfor assistant message events after a reasoning item has been emitted.Several event constructors use this expression:
When reasoning content exists, this produces
Truerather than the integer1. Python treatsboolas a subclass ofint, so this can pass local numeric checks, but downstream JSON consumers and event snapshots can observe the wrong type.Relevant code:
src/agents/models/chatcmpl_stream_handler.py: text, refusal, content-part-done, and output-item-done events use the boolean expression above.Debug information
mainat3854c124Repro steps
Stream Chat Completions chunks where reasoning content is emitted before regular text content. Inspect the
output_indexon the text/message events that follow the reasoning item.Current behavior: some events use
Trueasoutput_index.Expected behavior
All streamed response events should use integer
output_indexvalues, for example0for the reasoning item and1for the assistant message that follows it. No event should expose a booleanoutput_index.