Fix Auto Memory async loop mismatch by avoiding detached event loop#8
Open
lukekenny wants to merge 1 commit into
Open
Fix Auto Memory async loop mismatch by avoiding detached event loop#8lukekenny wants to merge 1 commit into
lukekenny wants to merge 1 commit into
Conversation
Davixk
requested changes
Dec 14, 2025
Owner
Davixk
left a comment
There was a problem hiding this comment.
this is only a problem with Redis enabled, as it modifies the event loop.
Redis is currently unsupported for Auto Memory, as noted in the readme document.
I believe Auto Memory should always be non-blocking, therefore I'm not willing to compromise this behavior for Redis support.
your proposal with asyncio.create_task(self.auto_memory(...)) does not achieve non-blocking behavior, as it will still block the request until the filter completes all coroutines.
the solution would be to detect when Redis is enabled, emit an explicit warning, and fall back to the blocking avenues, as I couldn't find any way to have non-blocking behavior when Redis was enabled, in my extensive testing a few months ago.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When auto_memory() is launched via _run_detached() (new thread + new asyncio event loop), it later awaits Open WebUI async internals such as query_memory() / add_memory() / update_memory_by_id(). Those internals create Futures bound to the main uvicorn event loop. Awaiting them from a different loop causes Auto Memory to fail with:
got Future <Future pending> attached to a different loopThis is reproducible even with uvicorn workers set to 1, because it’s a loop/thread mismatch (not a multi-process issue).
Fix
How to reproduce
Expected result
Auto Memory should successfully query related memories and add/update/delete memories without event-loop errors.