perf(read_file): cache line starts for paginated reads - #7152
Open
KYRIE66nb wants to merge 1 commit into
Open
Conversation
Cache-aware file reads intentionally page large files to preserve context budget, but continuing through the same file should not rescan every earlier page. This keeps the model-visible schema and output stable while reusing raw-text line starts discovered by prior reads. Constraint: Preserve read_file schema and output format so provider prompt-cache prefixes remain stable. Rejected: Build a full-file line index on first read | it would reintroduce large upfront IO and memory work for small windows. Confidence: high Scope-risk: narrow Directive: Keep cached seeks on raw disk text only; transformed encodings should stay on the streaming scanner until arbitrary-byte seek safety is proven. Cache-impact: low; implementation-only change to read_file execution, with no tool schema or prompt text changes. Cache-guard: go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -v Tested: GOPROXY=https://goproxy.cn,direct go test ./... -count=1 Tested: GOPROXY=https://goproxy.cn,direct go vet ./... Not-tested: desktop module tests; change is limited to the root Go module built-in read_file tool.
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
read_filereads.offset, avoiding repeated rescans of already-indexed pages.read_filetool schema and model-visible output format unchanged; decoded/overlay paths stay on the existing scanner.Issues
No linked issue.
Verification
go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -vgo test ./... -count=1go vet ./...Cache impact
Cache-impact: low; implementation-only change to
read_fileexecution, with no tool schema, system prompt, memory prefix, output style, or provider request serialization changes.Cache-guard:
go test ./internal/tool/builtin -run TestReadFileReusesLineOffsetCacheForRepeatedPagination -count=1 -vSystem-prompt-review: N/A