Fix OverlapRefinery crash when a float context_size rounds to zero tokens#632
Fix OverlapRefinery crash when a float context_size rounds to zero tokens#632santhreal wants to merge 1 commit into
Conversation
…kens With a float context_size (the default is 0.25), the per-chunk overlap size is int(context_size * prev_chunk.token_count). For a chunk of three or fewer tokens this rounds to 0. The recursive mode then split with a zero step (range(..., 0)) and raised 'ValueError: range() arg 3 must not be zero', and the token prefix mode treated tokens[-0:] as the whole chunk, copying the entire previous chunk in as overlap. Zero tokens means no overlap: return an empty context in that case. Reachable from the public OverlapRefinery.refine() with default settings whenever a chunk is small (small chunk_size, or a short trailing chunk).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe overlap refinery now returns empty context when a computed overlap size is zero or negative. Regression tests cover recursive suffix, recursive prefix, and token-based prefix behavior with small fractional context sizes. ChangesOverlap refinery zero-context handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses potential crashes and unintended chunk duplication in the overlap refinery by returning an empty string early when the effective context size is less than or equal to zero. This scenario typically occurs when a float context size rounds down to zero for small chunks. Unit tests have been added to cover these edge cases for both recursive and token modes. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
With a float
context_size(the default is0.25), the per-chunk overlap isint(context_size * prev_chunk.token_count). For a chunk of three or fewer tokens this rounds to0, and:mode="recursive"then splits with a zero step (range(..., 0)) and raisesValueError: range() arg 3 must not be zero;mode="token", method="prefix"usestokens[-0:], which is the whole chunk, so the entire previous chunk is copied in as overlap.Zero tokens means no overlap, so the two overlap-context routers now return an empty context in that case. Reachable from
OverlapRefinery.refine()with default settings whenever a chunk is small (a smallchunk_size, or a short trailing chunk). Added three regression tests; the full overlap suite passes (52).Summary by CodeRabbit