Repository navigation
fix(embedding): truncate plain list inputs to max_input_tokens (#5760) - #5771
Merged
qin-ctx merged 3 commits intoOct 15, 2026
Merged
Conversation
…ngine#5760) The OpenAI-compatible embedder's _prepare_embedding_input passed plain list[str] inputs straight through to the provider, skipping the max_input_tokens guard entirely, while the base prepare_embedding_input collapsed the same input to an empty string for text-only embedders and left items unbounded for multimodal embedders. The embedding queue contract explicitly allows list inputs, so any producer could submit oversized items that fail with provider errors (e.g. bigmodel 1210). Both guard layers now keep the list shape and bound every item individually via truncate_embedding_input; max_input_tokens=None keeps the historical passthrough. Single-string and dict-part multimodal behavior is unchanged.
qin-ctx
approved these changes
Oct 15, 2026
12 of 21 tasks
9 of 15 tasks
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.
Description
OpenAI-compatible
embed()andembed_async()preserve plainlist[str]inputs, but previously skippedmax_input_tokensfor these batches. Apply the existing truncation helper to each item when a limit is configured.For example, with
max_input_tokens=1,["first text", "x"]previously reached the provider unchanged; it now becomes["firs\n...(truncated for embedding)", "x"]. Item boundaries and short inputs are preserved. Without a configured limit, the batch passes through unchanged.Human Involvement
Related Issue
Related to #5760. This fixes the direct OpenAI batch-input guard; it does not establish an end-to-end fix for the reported directory-overview error.
Type of Change
Changes Made
truncate_embedding_input.EmbedderBasecontract unchanged: plain text or multimodal content parts. Queue acceptance of a list does not establish text-batch support for every provider.Testing
Updated an existing test instead of adding tests.
python -m pytest tests/unit/test_openai_embedder.py --no-cov -q: 10 passed. The no-new-tests check andgit diff --checkpass. Lint and format findings are unchanged from the base.Checklist
Screenshots (if applicable)
Not applicable.
Additional Notes
The current directory-overview converter emits a string, so this change is limited to the existing OpenAI direct-call batch behavior. Single-string and multimodal-part handling retain their existing behavior.