mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #20175] [CLOSED] fix: resolve SQLAlchemy connection exhaustion and enhance LLM reaction context for channels #41119
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20175
Author: @silentoplayz
Created: 12/25/2025
Status: ❌ Closed
Base:
dev← Head:feat/llm-reaction-context-and-fix📝 Commits (4)
8d7616dfeat: enhance LLM context with reactions and fix RichTextInput error1b8c7a6fix: resolve infinite recursion and connection pool exhaustion in message retrieval26e4937fix: ensure quoted messages are included in channel LLM context93fea9erefac: this works📊 Changes
3 files changed (+150 additions, -56 deletions)
View changed files
📝
backend/open_webui/models/messages.py(+107 -54)📝
backend/open_webui/routers/channels.py(+41 -2)📝
src/lib/components/common/RichTextInput.svelte(+2 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. Not targeting thedevbranch will lead to immediate closure of the PR.Changelog Entry
Description
This PR introduces three key improvements:
RecursionErrorandQueuePool limitexhaustion issue inbackend/open_webui/models/messages.py. The recursive fetching ofreply_to_messagewas causing infinite loops and depleting DB connections. This is fixed by:reply_to_message.dbsession in recursive/nested calls.UserNameResponseto handle ORM objects usingfrom_attributes=True.RangeError(invalid position) in theRichTextInput.sveltecomponent when the selection depth is 0.Added
model_response_handlerwithinbackend/open_webui/routers/channels.py.Changed
get_message_by_id,get_thread_replies_by_message_id, andget_reactions_by_message_idinbackend/open_webui/models/messages.pyto accept an optionaldbsession for reuse.self.get_message_by_idcalls forreply_to_messagewith inline DB queries to break the recursion loop.UserNameResponsevalidation to usefrom_attributes=True.Fixed
RecursionError: maximum recursion depth exceededwhen fetching nested message replies.QueuePool limit of size 5 overflow 10 reached(SQLAlchemy connection exhaustion) by ensuring session reuse.Uncaught RangeError: There is no position before the top-level nodeinsrc/lib/components/common/RichTextInput.svelte.reply_to_messageinto the LLM thread history if it's not already present.Additional Information
Screenshots
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.