[llm] Thread-safe mutable globals in ai_interaction (#729) #837

Closed
sleepy wants to merge 0 commits from fix/ai-interaction-thread-safety-729 into main
Owner

Fixes #729

Fixes #729
All five module-level mutable singletons (_session_manager, _memory_manager,
_memory_vector, _rag_manager, _personal_docs_manager) were written and read
without synchronisation. In a multi-threaded uvicorn server concurrent
requests could race on these shared references.

Fix: add a module-level threading.Lock and wrap every setter and getter with
it (double-checked locking pattern consistent with #709/#768). Every function
that reads a global now snapshots it into a local via the getter, so the lock
is never held during I/O.

Closes #729
sleepy closed this pull request 2026-06-04 11:42:17 +02:00

Pull request closed

Sign in to join this conversation.
No description provided.