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