feat(embed): skip oversized files with configurable size limit (#1)#157
Open
brettdavies wants to merge 1 commit intotobi:mainfrom
Open
feat(embed): skip oversized files with configurable size limit (#1)#157brettdavies wants to merge 1 commit intotobi:mainfrom
brettdavies wants to merge 1 commit intotobi:mainfrom
Conversation
* feat(embed): skip oversized files with configurable size limit Add a file size limit (default 5MB) to `qmd embed` that skips files exceeding the threshold. Configurable via QMD_MAX_EMBED_FILE_BYTES env var or bypassed with --no-size-limit flag. - Skip files over size limit with yellow warning during embed - Show "Skipped" count separately from "Pending" in `qmd status` - Add getEmbedBreakdown() query to distinguish actionable vs too-large - Refactor vectorIndex() to options object pattern - Validate env var with Math.floor for integer byte values - Add 10 unit tests for getMaxEmbedFileBytes config parsing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(embed): add tests for file size limit feature Cover getEmbedBreakdown SQL query (5 unit tests) and CLI behavior (5 integration tests) for status display, embed skip, --no-size-limit flag, and help text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
14 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.
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 OOMTesting
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 parsingKey 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.
Breaking Changes
Checklist