Repository navigation
perf: reuse prepared RAG retriever across requests - #619
Merged
sng-asyncfunc merged 1 commit intoNov 4, 2026
Merged
Conversation
Every request rebuilt the retriever from scratch (reload LocalDB, rebuild FAISS), which is slow and memory-hungry for large repos and can OOM during multi-page wiki generation. Cache the prepared RAG instance per repo/model/filter combination.
This was referenced Nov 7, 2026
sng-asyncfunc
pushed a commit
that referenced
this pull request
Nov 7, 2026
research_chat stored each request's prior turns in rag.memory. Since #619 the RAG object is cached and shared, so turns leaked into other requests and repeated on resend. Build the history from request.messages and remove the now-unused Memory class.
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
prepare_repo_index()creates a new RAG instance per request. Each construction reloads the LocalDB pickle and rebuilds the FAISS index — slow and memory-hungry for large repositories; consecutive requests can accumulate enough memory to OOM-kill the process.Solution
Cache the prepared instance in a module-level dict keyed by repo/type/token/provider/model and include/exclude filters so repeated requests reuse one retriever.