← Back to PRs

#12737: feat: add maxLines option for memory chunk splitting

by fastroc open 2026-02-09 15:44 View on GitHub →
agents stale
- Add optional maxLines parameter to chunking configuration - Split chunks when either maxChars OR maxLines threshold is reached - Improves search granularity for short-entry collections (quotes, facts, etc) - Add verbose logging to display maxLines in config output - Backward compatible: maxLines is optional, defaults to Infinity This fixes memory indexing where files with many short entries created too few chunks for effective search. Users can now configure maxLines to control chunk splitting based on line count. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR introduces an optional `maxLines` parameter to memory chunking and updates the markdown chunker to flush a chunk when either the character budget (`tokens`) or the line budget (`maxLines`) is reached. It also adds verbose per-file chunking diagnostics during indexing. Within the codebase, chunking configuration is resolved in `src/agents/memory-search.ts` and then consumed by the memory indexer (`src/memory/manager.ts`) which calls `chunkMarkdown` from `src/memory/internal.ts` to split file content into chunks before embedding and indexing. <h3>Confidence Score: 2/5</h3> - This PR is not safe to merge as-is because the new maxLines option is computed but not propagated into the resolved config, so the feature does not work. - The chunker supports maxLines, but `ResolvedMemorySearchConfig` currently drops `maxLines` when returning the final chunking config, making the change ineffective. Minor logging correctness issues also exist for falsy numeric values. - src/agents/memory-search.ts (config resolution); src/memory/manager.ts (verbose logging edge case) <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs