feat: add configurable embedding chunk limit#73
Merged
jflowers merged 1 commit intoJun 26, 2026
Conversation
- Add MaxChunkChars field to ProviderConfig with config/env resolution (DEWEY_CHUNK_MAX_CHARS env var, embedding.max_chunk_chars config field) - Change PrepareChunk to accept maxChars parameter, removing global constant - Thread configured chunk limit through GenerateEmbeddings to all 11 production call sites via tool structs and server options - Add defensive guard for negative/zero maxChars in PrepareChunk - Add legacy model advisory to dewey doctor (INFO marker for granite-embedding:30m) - Extract resolveMaxChunkChars() helper to DRY env var parsing - Default chunk limit increases from 768 to 12288 (~8192 tokens) - Default model stays granite-embedding:30m (R2 not yet on Ollama, unbound-force#53) - Add 12 new tests: config resolution, chunker boundaries, doctor advisory - Update AGENTS.md and README.md with new env var and config field Refs: unbound-force#53
yvonnedevlinrh
approved these changes
Jun 26, 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
Implements #53 — configurable embedding chunk limit with preparation for Granite Embedding R2 model upgrade.
New Capability
DEWEY_CHUNK_MAX_CHARSenv var andembedding.max_chunk_charsconfig field control the maximum chunk character limit sent to the embedding model. Default increased from 768 to 12288 (~8192 tokens).Changes
PrepareChunknow accepts amaxChars intparameter instead of using a package-level constant (eliminates global state)GenerateEmbeddings→ all 11 production call sites via tool structs and server optionsdewey doctordisplays an informational advisory when the legacygranite-embedding:30mmodel is configureddewey inittemplate includes the newmax_chunk_charsconfig optionmaxCharsinPrepareChunkresolveMaxChunkChars()helper (DRY env var parsing)Guard Clause
Default model stays
granite-embedding:30m— R2 is not yet on Ollama. TODO comment tracks the pending update.Tests
Documentation
AGENTS.md: chunk size limit resolution precedence, config exampleREADME.md:DEWEY_CHUNK_MAX_CHARSin env var tables, config examplesOpenSpec Artifacts
openspec/changes/upgrade-embedding-model-r2/— proposal, design, specs, tasks