Skip to content

reasoning_item_created never called on stream #1025

Open
@typefox09

Description

@typefox09

Docs say the type of streamed events can be:

name: Literal[
    "message_output_created",
    "handoff_requested",
    "handoff_occured",
    "tool_called",
    "tool_output",
    "reasoning_item_created",
    "mcp_approval_requested",
    "mcp_list_tools",
]

However reasoning_item_created is never triggered;

Code for reference:

    async for event in result.stream_events():

        # 1. Stream model tokens (raw_response_event)
        if event.type == "raw_response_event":

            # # a. Model reasoning / thinking tokens
            if isinstance(event.data, ResponseReasoningSummaryTextDeltaEvent):
                if not thinking_mode:
                    thinking_mode = True
                    print()
                    print("\nThinking...\n", end="", flush=True)
                print(event.data.delta, end="", flush=True)
                thinking_text += event.data.delta
                continue

            # # b. Final assistant answer tokens
            if isinstance(event.data, ResponseTextDeltaEvent):
                if thinking_mode:
                    # Close the thinking section with a newline before the answer starts
                    thinking_mode = False
                    print("\n", end="", flush=True)
                if not answer_started:
                    answer_started = True
                    print()
                    print("Final answer...\n", end="", flush=True)
                print(event.data.delta, end="", flush=True)
                current_text += event.data.delta
                continue


        # 2. Handle higher-level events
        if event.type == "agent_updated_stream_event":
            print(f"\n-- Agent updated: {event.new_agent.name}\n")
            continue

        if event.type == "run_item_stream_event":

            if event.item.type == 'reasoning_item_created':
                print(event)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-more-infoWaiting for a reply/more info from the authorquestionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions