feat(embed): skip oversized files with configurable size limit#153
Closed
brettdavies wants to merge 1 commit intotobi:mainfrom
Closed
feat(embed): skip oversized files with configurable size limit#153brettdavies wants to merge 1 commit intotobi:mainfrom
brettdavies wants to merge 1 commit intotobi:mainfrom
Conversation
Add content size limit during embedding (default 5MB). Files exceeding the limit are skipped with a warning before tokenization. - Add getEmbedBreakdown() to split pending docs into embeddable vs too-large - Add DEFAULT_MAX_EMBED_FILE_BYTES constant (5MB) in store.ts - Add getMaxEmbedFileBytes() helper with QMD_MAX_EMBED_FILE_BYTES env var - Add --no-size-limit CLI flag to bypass size checks - Show "Skipped: N exceed X size limit" in qmd status output - Replace TextEncoder.encode().length with Buffer.byteLength() (avoids unnecessary memory allocation in the chunking loop) - Add 20 automated tests (10 env var, 5 SQL query, 5 CLI integration) Co-Authored-By: Claude Opus 4.6 <[email protected]>
This was referenced Feb 11, 2026
13 tasks
Author
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
Add a configurable content size limit to
qmd embedthat skips oversized files before tokenization. Prevents OOM on constrained systems and improves embedding quality by avoiding excessively large documents that produce too many diluted chunks.Changes
getEmbedBreakdown()SQL query instore.tsto split pending docs into embeddable vs too-largeDEFAULT_MAX_EMBED_FILE_BYTESconstant (5MB) instore.tsgetMaxEmbedFileBytes()helper withQMD_MAX_EMBED_FILE_BYTESenv var override--no-size-limitCLI flag to bypass size checks for one-off full embedsqmd statusoutputnew TextEncoder().encode(str).lengthwithBuffer.byteLength(str, 'utf8')(avoids unnecessary memory allocation in the chunking loop)Type of Change
feat: New feature (non-breaking change which adds functionality)test: Adding or updating testsRelated Issues/Stories
src/mcp.ts, not embedding OOM)vectorIndex()Testing
Test Summary:
getMaxEmbedFileBytesenv var parsing + 5getEmbedBreakdownSQL query)--no-size-limitflag, help text)Files Modified
Modified:
src/store.ts-- addgetEmbedBreakdown()function andDEFAULT_MAX_EMBED_FILE_BYTESconstantsrc/qmd.ts-- addgetMaxEmbedFileBytes(),--no-size-limitflag, skip logic invectorIndex(), breakdown display instatussrc/store.test.ts-- adddescribe("getEmbedBreakdown")with 5 unit testssrc/cli.test.ts-- adddescribe("CLI Embed File Size Limit")with 5 integration testsCreated:
src/embed-config.test.ts-- 10 unit tests forgetMaxEmbedFileBytes()env var parsingDeleted:
Key Features
qmd embedstays fast even when all files are too largeqmd statusshows a breakdown: pending count vs skipped count--no-size-limitflag overrides the limit for a single run without changing configQMD_MAX_EMBED_FILE_BYTESenv var allows per-environment tuningConfiguration
Motivation
Large files cause two problems during embedding:
Skipping with a clear warning is better than crashing or producing bad embeddings.
Future Possibilities
If per-extension limits are useful, they could be added via per-extension constants, YAML config per collection, or per-extension env vars. Happy to add any of these if you'd find them useful.
Breaking Changes
Deployment Notes
Checklist