refactor: move background tasks handler call to ensure consistent execution in chat response handlers (#24717)

This commit is contained in:
Jacob Leksan
2026-06-01 16:50:15 -04:00
committed by GitHub
parent 974b13839e
commit 80da840ae5
+2 -2
View File
@@ -3545,13 +3545,13 @@ async def non_streaming_chat_response_handler(response, ctx):
},
)
await background_tasks_handler(ctx)
ctx['assistant_message'] = {
'content': content,
'output': response_output,
**({'usage': usage} if usage else {}),
}
await outlet_filter_handler(ctx)
await background_tasks_handler(ctx)
response = build_response_object(response, merge_events_into_response(response_data, events))
except Exception as e:
@@ -5164,13 +5164,13 @@ async def streaming_chat_response_handler(response, ctx):
}
)
await background_tasks_handler(ctx)
ctx['assistant_message'] = {
'content': serialize_output(output),
'output': output,
**({'usage': usage} if usage else {}),
}
await outlet_filter_handler(ctx)
await background_tasks_handler(ctx)
except asyncio.CancelledError:
log.warning('Task was cancelled!')