fix(embed): split Gemini batchEmbedContents into <=100-request calls#200
Merged
Conversation
Gemini's batchEmbedContents rejects a batch with more than 100 requests (`INVALID_ARGUMENT: at most 100 requests can be in one batch`). The embedder sent every text of a document in one call, so any document chunking into >100 blocks 400'd — breaking both the live server's /ingest/upload AND the offline loader's Gemini build on larger PDFs. GeminiEmbedder::embed now splits `texts` into <=100-text sub-batches (extracted embed_batch helper), preserving order across calls. Test: wiremock test embeds 150 texts, asserts each sub-batch is <=100, exactly 2 calls are made (100+50), and all 150 vectors return. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Gemini caps a batch at 100 requests; documents chunking into >100 blocks 400'd (breaks live /ingest/upload AND the offline loader's Gemini build on large PDFs). Split into <=100-text sub-batches, order preserved. Wiremock test: 150 texts → 2 calls (100+50), each <=100, all 150 vectors returned.
🤖 Generated with Claude Code