Auto-chunk TEI embedding requests to respect server batch size limit#4029
Merged
aponcedeleonch merged 1 commit intomainfrom Mar 6, 2026
Merged
Auto-chunk TEI embedding requests to respect server batch size limit#4029aponcedeleonch merged 1 commit intomainfrom
aponcedeleonch merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4029 +/- ##
==========================================
- Coverage 68.61% 68.59% -0.03%
==========================================
Files 444 444
Lines 45187 45253 +66
==========================================
+ Hits 31007 31040 +33
- Misses 11780 11813 +33
Partials 2400 2400 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TEI (Text Embeddings Inference) does not automatically batch embedding requests — it rejects requests that exceed max_client_batch_size with a 422 error. This wasn't caught earlier because the Optimizer was indexing fewer than 32 tools (the default limit). Once we exceeded that threshold, upserts started failing. Query the TEI /info endpoint at client creation to discover max_client_batch_size, then split EmbedBatch requests into chunks that fit within the limit. Falls back to a default of 32 when /info is unavailable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
00fd472 to
ab76655
Compare
jerm-dro
approved these changes
Mar 6, 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
TEI (Text Embeddings Inference), which the Optimizer uses for embeddings, does not automatically batch requests that exceed its
max_client_batch_size— it simply rejects them with a 422 error. This bug hadn't surfaced because we were indexing fewer than 32 tools (the default server limit). Once that threshold was exceeded, upserts started failing.This PR fixes the issue by:
/infoendpoint at client creation to discovermax_client_batch_sizeEmbedBatchrequests into chunks that respect the server limit/infois unavailableTest plan
/infoendpoint fetching (success, zero value, missing field, server error, invalid JSON, connection refused)newTEIClientwith/infointegration and fallback behavior🤖 Generated with Claude Code