Skip to content

Chat Completions streaming computes assistant output_index with a bool expression #3109

@Aphroq

Description

@Aphroq

Please read this first

  • Have you read the docs? Agents SDK docs
  • Have you searched for related issues? Others may have faced similar issues.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions