diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index 81e196360a..1535cce4b4 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -1481,12 +1481,11 @@ async def post_new_message( except Exception as e: log.debug(e) - active_user_ids = await get_user_ids_from_room(f'channel:{channel.id}') - # NOTE: We intentionally do NOT pass db to background_handler. # Background tasks should manage their own short-lived sessions to avoid # holding database connections during slow operations (e.g., LLM calls). async def background_handler(): + active_user_ids = await get_user_ids_from_room(f'channel:{channel.id}') await create_task(None, app_channel_reply_handler(channel.id, message.id, user.id)) await model_response_handler(request, channel, message, user) await send_notification(