fix: stream post-tool-call thinking into the Thoughts section (#29052)

After a tool call, the model's thinking was streamed into the chat as if it were the main response, and only jumped into the collapsed Thoughts section once the turn finished. Every further tool call repeated it.

Each tool round appended an empty placeholder message item to the output and sent it to the browser, then dropped it again from the copy used to offset the next round's item indices. The browser therefore held one item more than the backend counted, so the first thinking chunk of the next round was written into that leftover message item and rendered as normal text until the finished output replaced it.

The placeholder is removed. It was never needed: a message item is already created when actual content arrives, and dropping it also stops an empty assistant message being sent back to the model on the follow-up request.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Classic298 2026-08-27 22:56:00 +02:00 committed by GitHub
parent fa7de50c60
commit 87bed3f0b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5790,17 +5790,6 @@ async def streaming_chat_response_handler(response, ctx):
item['arguments'] = tc.get('function', {}).get('arguments', '{}')
break
# Append a new empty message item for the next response
output.append(
{
'type': 'message',
'id': output_id('msg'),
'status': 'in_progress',
'role': 'assistant',
'content': [{'type': 'output_text', 'text': ''}],
}
)
# Emit citation sources to the frontend for display
if citations_enabled:
for source in tool_call_sources: