perf(acp): read line ranges over ACP without fetching whole files#996
Open
7Sageer wants to merge 4 commits into
Open
perf(acp): read line ranges over ACP without fetching whole files#9967Sageer wants to merge 4 commits into
7Sageer wants to merge 4 commits into
Conversation
AcpKaos gains readLineRange, which passes ACP fs/read_text_file's native line/limit parameters so a compliant client returns only the requested window. The Read tool now uses it for forward range reads when the Kaos provides readLineRange but not scanTextFile (i.e. ACP), omitting the total-lines line that would otherwise require a full read. ACP range reads no longer transfer the whole file.
🦋 Changeset detectedLatest commit: dbc0257 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
The media sniff in ReadTool runs readTextPreview on every Read. Over ACP it fetched the whole file via readText and sliced it, so a range Read still transferred the whole file once before the window read. Use readLineRange({ startLine: 1, maxLines: 1 }) instead so a compliant client returns only line 1; the defensive cap keeps non-compliant clients bounded too. detectFileType only needs the leading magic bytes plus a NUL scan, both covered by line 1.
|
You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard. |
Collaborator
Author
|
@codex review 😭 |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Note
This PR is stacked on #971. Only the last two commits are new; the rest is #971. Please review and merge #971 first — once it lands, this diff collapses to the ACP-only changes.
Related Issue
Builds on #971 (no separate issue).
Problem
When the agent reads a line range of a file over ACP,
AcpKaosfetches the entire file throughfs/read_text_fileand slices it in memory, because it does not use the protocol's nativeline/limitparameters. For large files this transfers the whole file over the wire even when only a small window is needed.What changed
AcpKaosnow passesline/limittofs/read_text_filefor forward range reads, so a compliant client returns only the requested window instead of the whole file.AcpKaosdefensively truncates to the requested limit if the client ignores it.AcpKaosrange read and the Read tool's ACP path.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. (No doc update — internal ACP read-path optimization; the read tool description does not document the total-lines line.)