fix: stream reasoning deltas when the provider also sends reasoning_details

Providers such as OpenRouter emit reasoning_details alongside the reasoning
text on the same delta. Merging those details cleared the pending event
unconditionally, discarding the response.reasoning_text.delta that had just
been built, so the client received no reasoning until the response completed
and the thinking block only appeared after generation finished.

The event is now only dropped when the details were all there was to report.
Details persistence is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uuEg4AXPs9zE3vVUfN1Fj
This commit is contained in:
Claude 2026-08-27 09:14:54 +00:00
parent 5d7fc35eda
commit 56177f34fd
No known key found for this signature in database

View file

@ -5222,7 +5222,12 @@ async def streaming_chat_response_handler(response, ctx):
reasoning_detail_items,
)
await save_current_response_stream()
data = None
# Providers such as OpenRouter send reasoning_details
# alongside the reasoning text: only drop the event when
# the details were all there was to report, otherwise the
# reasoning delta never reaches the client.
if not reasoning_content:
data = None
if value:
if (