GPT-mini sometimes hanging on response.output_item.added of type reasoning

When using the Responses API with streaming, sometimes the stream hangs on response.output_item.added (type: reasoning) until it times out (like 60sec). I print the events and the last one is this one:

ResponseOutputItemAddedEvent(item=ResponseReasoningItem(id=‘rs_0798…d18’, summary=, type=‘reasoning’, content=None, encrypted_content=None, status=None), output_index=0, sequence_number=2, type=‘response.output_item.added’)

Does anyone have an idea why that might be? If I switch to gpt-4.1-mini, my code works fine (no reasoning events).

My simplified code logic is basically:

while ctx.keep_reasoning:
    stream = client.responses.create(...)
    
    for ev in stream:
        print(ev)

        # yield ev chunks based on type
        # [...]
        if t == "response.function_call_arguments.done":
            print("Breaking due to tool call")
            break
        if t == "response.output_text.done":
            # yield output text
            # [...]
            ctx.keep_reasoning = False

        # handle other event types...
        # [...]

    stream.close()

    # call any tools
    # [...]
    continue

You should allow a much higher timeout, or deliberately close the client connection if it seems the AI is generating for far too long. A timeout of 60 seconds may be from the host platform you are running on, as the openai library gives 15 minutes, and the API, much more than that.

The outer loop seems odd, if it was meant to refer to the AI model continuing to generate. If you submit an input that never gives a collected output_text, it runs forever? There are parameters and inputs that cannot make the promise that the terminal state is user-readable text in that collector value.

The likely issue is the AI model is in a loop, continuing to output a string of nonsense into its internal reasoning. Or that you encountered a run that is just performing extremely poorly in token rate generation.

  • ensure longer timeout is possible on the platform.
  • self-monitor your timeout between events (such as response.output_item.added), and exit the context manager to close the connection.