feat(rag): make the RAG embed batch size configurable (#4327) - #4350
Merged
Conversation
EMBED_BATCH was a hardcoded 96 with no override, unlike its sibling RAG_DIMENSIONS/QDRANT_DIM. Self-host operators tuning Ollama throughput on their own hardware (e.g. GPU-accelerated) had no way to adjust it without a code change. Adds AI_EMBED_BATCH, threaded through RagInfra the same way embeddingDimensions already is. Benchmarked on an RTX A5000: 96 is already near-optimal (~34ms/chunk vs ~70ms/chunk at 32, only ~3% further gain up to 384) -- no default change, this just adds the tuning knob for different hardware/models.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4350 +/- ##
=======================================
Coverage 93.95% 93.95%
=======================================
Files 399 399
Lines 36782 36786 +4
Branches 13436 13440 +4
=======================================
+ Hits 34557 34561 +4
Misses 1569 1569
Partials 656 656
🚀 New features to boost your workflow:
|
This was referenced Jul 9, 2026
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.
Summary
EMBED_BATCH(items per RAG embed-provider call) was a hardcoded96insrc/review/rag.tswith no env override, unlike its siblingRAG_DIMENSIONS/QDRANT_DIM. AddsAI_EMBED_BATCH, threaded throughRagInfrathe exact same wayembeddingDimensionsalready is, so self-host operators can tune throughput for their own hardware without a code change.Part of #4327.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlint(vianpm run test:ci)npm run typecheck(vianpm run test:ci)npm run test:coveragelocally —rag.ts100% branch coverage (174/174) including the new code;adapters.ts's one pre-existing partial branch (line 43) is unrelated code this PR does not touchnpm run test:workers(vianpm run test:ci)npm run build:mcp(vianpm run test:ci)npm run test:mcp-pack(vianpm run test:ci)npm run ui:openapi:check(vianpm run test:ci) — no API/OpenAPI surface touchednpm run ui:lint(vianpm run test:ci) — no UI files touchednpm run ui:typecheck(vianpm run test:ci)npm run ui:build(vianpm run test:ci)npm audit --audit-level=moderate— 0 vulnerabilitiesembedBatchoverride) has unit tests covering both theragEmbedBatchFromEnvparser branches and the plumbing throughembedTexts,upsertChunks,retrieveContext, andcreateReviewAdaptersRan
npm run test:citwice end-to-end (full unsharded suite) to confirm green; one unrelated pre-existing flaky test (queue.test.ts's#3899concurrency-bound regression, nothing to do with RAG/embeddings) failed on the first run under heavy background load and passed both in isolation and on a clean re-run.Safety
UI Evidencesection. — N/A, no UI change..env.exampledocuments the new var); changelog itself not touched (not a release-prep PR).Notes
cf-typegenregeneration needed —AI_EMBED_BATCHis a plainenv.d.tsfield read directly insrc/review/adapters.ts, outside the scanned roots forselfhost:env-reference(same treatment as the existingQDRANT_DIM, which is separately documented where it's read insidesrc/selfhost/**).