fix(vector-stores): survive a failing vector store search in the chat completions hook - #39495
Conversation
… completions hook One unreachable vector store used to wipe out every store's context on a chat completion carrying vector_store_ids: the search raised, the blanket handler returned the original messages, and the request answered with no retrieved context at all. Each store's search now has its own handler that warns with the vector store id and moves on to the next store. The same loop appended every store's results to the original messages instead of the running copy, so with two healthy stores only the last one reached the model. It now chains through modified_messages. The Router is injected through a ProxyRuntime protocol instead of an in-function litellm.proxy.proxy_server import, so the hook's routing can be driven in tests without touching proxy globals.
Greptile SummaryThe PR makes vector-store searches independently recoverable and accumulates context from every successful store.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/integrations/vector_store_integrations/vector_store_pre_call_hook.py | Adds injectable proxy runtime access, isolates individual search failures, and accumulates context across successful vector stores without an identified blocking defect. |
| tests/test_litellm/integrations/vector_store_integrations/test_vector_store_pre_call_hook.py | Adds strongly typed regression coverage for router selection, fallback behavior, context accumulation, warning details, and partial failures. |
Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6966a33. Configure here.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b503bca. Configure here.
…itellm_vector_store_hook_router_injection
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0e537d2. Configure here.
00faaa1
into
litellm_internal_staging
Follows #39474, now merged, which moved S3 Vectors query embeddings onto the shared executor.
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer whose chat app searches several vector stores loses all retrieved context the moment one store is unreachable, and the log never says which one
"vector_store_ids": ["<store whose index was deleted>", "<healthy runbook store>"]and a question the runbook answers["<runbook store>", "<rollback window store>"], asking for a fact from each, and the answer still only has the second store's factAfter: the same requests answer from every store that is reachable, and the log names the one that is not
"vector_store_ids": ["<store whose index was deleted>", "<healthy runbook store>"]vector_store_id=<store whose index was deleted>and the provider error next to it, so the bad store is obviousRelevant issues
Linear ticket
Resolves LIT-6752
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Two proxies on the same Postgres, one per side, both with 2 workers, real OpenAI models and real S3 Vectors stores in eu-central-1.
Shared setup, run once on the head proxy: two documents ingested into their own S3 Vectors stores, plus a third store registered against an index that does not exist.
litellm-index-705d1dd1holds "The Kyoto failover runbook: drain the Osaka queue before flipping DNS, then page the on-call owl." andlitellm-index-995246bdholds "The Kyoto rollback window is 14 minutes, after which the failover becomes permanent."lit6752-missing-p5points at an S3 Vectors index that was never created.Before (066d5f0)
One unreachable store next to a healthy one
The healthy store never gets searched, so the answer is the model's own guess and no search results come back.
Two healthy stores
Only the last store's fact (14 minutes) is real; the drain target is invented, because the first store's context never reached the model.
After (0e537d2)
One unreachable store next to a healthy one
Two healthy stores
Both stores' facts are in the answer.
Type
🐛 Bug Fix
Caveats (if any)
Medium
Low
Final Attestation
Note
Medium Risk
Changes RAG pre-call behavior for all multi-store chat requests; failures are now non-fatal per store, which improves availability but can hide misconfiguration unless operators watch warnings.
Overview
Hardens the vector store pre-call hook for chat completions when requests list multiple
vector_store_ids.Per-store failures are caught inside the search loop: a warning logs the failing
vector_store_idand the hook continues so healthy stores still run. The chat request is not aborted for one bad index.Multi-store context now chains correctly by appending each successful search onto
modified_messagesinstead of the original message list, so every reachable store contributes context (not only the last one).Proxy access is refactored through an injectable
ProxyRuntime(ProxyServerRuntimeby default) forllm_routerandprisma_client, replacing inlineproxy_serverimports in the hook path. New unit tests cover router injection, SDK fallback, partial failure, and the default runtime.Reviewed by Cursor Bugbot for commit 0e537d2. Bugbot is set up for automated code reviews on this repo. Configure here.