#12737: feat: add maxLines option for memory chunk splitting
agents
stale
Cluster:
Memory Management Enhancements
- 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
#9089: feat(memory): semantic markdown chunking for better recall
by Kuroro92100 · 2026-02-04
75.8%
#12425: feat(core): Native Token Optimization Defaults (Pruning, Compaction...
by oneles · 2026-02-09
73.9%
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
73.3%
#5808: fix(memory): truncate oversized chunks before embedding
by douvy · 2026-02-01
73.1%
#8890: fix: increase bash output chunk limit from 8KB to 32KB
by joetomasone · 2026-02-04
72.5%
#18919: feat: importance-weighted temporal decay for memory search
by ruypang · 2026-02-17
72.1%
#20149: fix(memory): expose index concurrency as config option
by togotago · 2026-02-18
72.0%
#8919: Pr/memory flush improvements
by shortbus · 2026-02-04
71.8%
#13792: Claude/openclaw token efficiency q ni2s
by imecostalima · 2026-02-11
71.7%
#2958: fix(media): wire tools.media.image.maxBytes config to image processin…
by shamsulalam1114 · 2026-01-27
71.7%