Repository navigation
fix(rag): reject incomplete embedding batches - #3860
Conversation
Request changesThis replaces the RAG indexer's one-by-one fallback with a hard failure whenever the embedding backend returns fewer, empty, or differently-sized vectors than requested — the right call, since the old path silently paired vectors with the wrong passages. The alignment fix itself is solid and well tested; what's missing is the retry the old fallback was accidentally providing. Headline issue — a warming-up embedder will now abort a whole document. Lemonade answers HTTP 200 with too few (or zero) vectors while the model is still loading. The old one-by-one path re-asked and usually succeeded a moment later; the new code fails on the first short answer and tells the user to retry indexing by hand — a full re-run of a large PDF for a race that clears itself in seconds. GAIA's code-index module already hit exactly this and solved it by re-sending the same batch up to twice before giving up; reuse that here and the fix keeps its strictness without the new fragility. Secondary — one failure mode gets advice that will never work. A chunk that's still too long for the embedder comes back as an empty vector, and indexing now stops with a message telling the user to check that the model is loaded and retry. That retry is deterministic: the same document fails forever, with nothing in the error pointing at the real cause. Worth naming the over-long-chunk possibility in the message. Real-world evidenceNo evidence bundle was produced for this PR, and The gap worth closing before merge: the PR shows unit tests for the failure paths, but nothing showing a normal document still indexes end-to-end now that the fallback is gone — one 🔍 Technical details🟡 Short/empty HTTP-200 responses are no longer retried (
|
|
Addressed the warm-up and alignment feedback in 5027a7e. Incomplete vectors now use the existing bounded retry loop for the same batch, response indices are validated and ordered, and errors include the token-limit/chunk-size remedy. All 27 focused alignment/transaction tests passed. A live Lemonade SDK run indexed a temporary document successfully with matching chunk and vector counts. |
amd#3860 landed the same guard on main with different messages and a batch retry in place of the one-by-one fallback; the invariant these pin — raise rather than shift chunks against misaligned vectors — is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]>
An incomplete embedding batch could pair vectors with the wrong passages or files. RAG now validates whole batches and response indices before publishing index changes, using the existing bounded retry policy for a warming model and preserving existing documents when indexing fails.
Fixes #3530.
Test plan: