Repository navigation
feat(core): cap read_file at 20,000 chars with offset/limit continuation (#211 part 3) - #357
Merged
Merged
Conversation
…ion (#211 part 3) read_file previously returned the whole file (up to 1 MiB), the largest single history body re-sent on every step. It now returns at most 20,000 characters per call and accepts optional offset/limit (characters, UTF-8 boundary-safe). The result keeps path/content/bytes/hash and adds truncated, total_chars and next_offset (only when truncated). Part of #211. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Oct 9, 2026
Merged
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.
What
read_filenow returns at most 20,000 characters per call and accepts optionaloffset/limit(characters, UTF-8 boundary-safe). The result addstruncated,total_charsandnext_offset(only when truncated) so the model can continue reading.Why
read_filewas the largest single history body (whole file up to 1 MiB), re-sent on every later step. git/web are already capped at 20,000 chars. Decision 7 of #211. Part of #211 (follow-ups remain open).Changes
crates/tole-core/src/read_file.rs: head cap (pub(crate) MAX_READ_CHARS),offset/limitparsing (non-negative integers,limit >= 1, larger limit silently clamped to 20,000), slicing viachar_indices;offset >= total_charsreturns empty content,truncated:falseand anote(not an error). Result before:{path, content, bytes, hash}; after: same plustruncated,total_chars,next_offset?.bytesandhashstill describe the WHOLE file, soedit_file.old_hashanchors are unaffected.summary(): +109 chars in the summary, +165 chars of schema (offset,limit) = 274 added spec characters.read_file.rsandcrates/tole-cli/tests/read_file_chunks_e2e.rs. No existing test needed adapting.### Changed.Testing
next_offset == 20000), multibyte (é,日本語, emoji) reassembly for limits 1/2/3/7/13/1000, offset in chars, offset beyond end, limit clamp, negative/float/string/bool/array offset|limit rejected, CRLF, empty file.next_offset) and the mission concludes.executeslicing is reverted.evals_tier1(unmodified),cora review --staged: clean.🤖 Generated with Claude Code