fix: replies cut off at the token limit on a Responses API connection lose their token usage (#33619)

When a streamed reply from a Responses API connection stopped early, for example at the token limit or through a content filter, its token counts were lost. The chat showed no usage for that reply and the admin analytics recorded zero tokens for it. Such replies now keep the usage the provider reported, the same as replies that finished normally.

Fixes #33615
This commit is contained in:
Classic298 2026-11-03 13:04:51 +01:00 • committed by GitHub
parent fa09d74644
commit aa1326eaea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -835,7 +835,7 @@ def handle_responses_streaming_event(
return current_output, None
elif event_type == 'response.completed':
elif event_type in ('response.completed', 'response.incomplete'):
# State Machine Event: Completed
response_data = data.get('response', {})
final_output = response_data.get('output')