fix: Google embedMany loses per-value content alignment when batching more than 100 inputs - #21143
Open
ai-sdk-factory[bot] wants to merge 3 commits into
Open
ai-sdk-factory[bot] wants to merge 3 commits into
ai-sdk-factory[bot] wants to merge 3 commits into
Conversation
Co-authored-by: brennanbutler01 <64561607+brennanbutler01@users.noreply.github.com>
1 task
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.
Background
Google embedMany rejected 101 inputs with matching per-value content before sending a request instead of batching all embeddings.
Root Cause
embedMany split values at the provider's 100-item limit but reused the complete providerOptions for every chunk. Google therefore compared 101 content entries with the first 100-value batch.
Summary
Added an embedding-model capability for transforming provider options per batch. Google now validates the complete content array and slices it using each batch's original index range, including null entries.
Testing
Added coverage for per-batch option transformation, Google content slicing, index alignment, and capability preservation through wrapped embedding models. Added patch changesets for ai, google, and provider-utils.
End-to-end Validation
replay_original_reproduction(pnpm -C examples/ai-functions exec tsx src/reproduction/google-embed-many-content-batching.ts) completed successfully without the bug signal.pnpm -C examples/ai-functions exec tsx -e "<101-value Google embedMany call>"returned 101 embeddings across two provider responses.Related Issues
Fixes #21095
Closes #21096