Honor view_file line range and cap result size - #303
Merged
Conversation
zbl94
force-pushed
the
fix-view-file-line-range
branch
from
July 14, 2026 18:40
80a7415 to
75efc73
Compare
wjjclaud
reviewed
Jul 14, 2026
wjjclaud
left a comment
Collaborator
There was a problem hiding this comment.
I don't see where next_content_offset is reported. Is this intentional?
Collaborator
Author
It turns out that this field, |
execViewFile read the whole file and ignored the agent's StartLine/EndLine,
so viewing a large file returned its entire content as the tool result --
a ~900KB blob for a 3k-line CSV stalled the following turn.
Implement the Antigravity view_file contract (1-indexed inclusive line range
with slice-notation windowing) plus defensive caps:
- StartLine/EndLine window (neither=first N lines; start-only=next N forward;
end-only=previous N backward; both=precise range, capped to N).
- viewFileMaxLines / viewFileMaxBytes caps so a large file can never blob.
- ContentOffset honored as the read position within the windowed content.
The result payload is just {"content": ...}; the view_file result schema is
defined server-side, so no extra fields are added.
Adds intArg/intArgOK helpers and tests for windowing, byte cap, offset read,
and range honoring.
zbl94
force-pushed
the
fix-view-file-line-range
branch
4 times, most recently
from
July 15, 2026 07:52
623c592 to
a5acabf
Compare
Address review feedback on the byte cap: - applyByteWindow backs the cut off to the last complete UTF-8 rune so a multi-byte character straddling viewFileMaxBytes is never split (raw byte slicing could produce invalid UTF-8, corrupting the last char and JSON serialization). - execViewFile returns the metadata the server needs to distinguish a complete read from a paginated/byte-truncated one: content, start_line/ end_line (0-indexed inclusive served range), content_offset, line_range_bytes (total bytes of the line range pre-byte-cap), and num_lines/num_bytes. The server detects truncation via content_offset+len(content) < line_range_bytes and prompts the model to resume from that offset. A paired server change reads these fields instead of hardcoding start_line=0/end_line=last. Adds tests for UTF-8 boundary capping, pagination metadata, and resume.
zbl94
force-pushed
the
fix-view-file-line-range
branch
from
July 15, 2026 08:03
a5acabf to
1d44229
Compare
wjjclaud
approved these changes
Jul 15, 2026
joycel-github
approved these changes
Jul 15, 2026
rakyll
pushed a commit
that referenced
this pull request
Jul 21, 2026
The dummyAgent test fixture defined a HealthCheck method that was never part of the agent.Agent interface and had no callers. Remove it so the fixture matches the actual interface (Connect, Close) and nothing else.
rakyll
pushed a commit
that referenced
this pull request
Jul 21, 2026
* Honor view_file line range and cap result size
execViewFile read the whole file and ignored the agent's StartLine/EndLine,
so viewing a large file returned its entire content as the tool result --
a ~900KB blob for a 3k-line CSV stalled the following turn.
Implement the Antigravity view_file contract (1-indexed inclusive line range
with slice-notation windowing) plus defensive caps:
- StartLine/EndLine window (neither=first N lines; start-only=next N forward;
end-only=previous N backward; both=precise range, capped to N).
- viewFileMaxLines / viewFileMaxBytes caps so a large file can never blob.
- ContentOffset honored as the read position within the windowed content.
The result payload is just {"content": ...}; the view_file result schema is
defined server-side, so no extra fields are added.
Adds intArg/intArgOK helpers and tests for windowing, byte cap, offset read,
and range honoring.
* view_file: UTF-8-safe byte cap + pagination metadata
Address review feedback on the byte cap:
- applyByteWindow backs the cut off to the last complete UTF-8 rune so a
multi-byte character straddling viewFileMaxBytes is never split (raw byte
slicing could produce invalid UTF-8, corrupting the last char and JSON
serialization).
- execViewFile returns the metadata the server needs to distinguish a
complete read from a paginated/byte-truncated one: content, start_line/
end_line (0-indexed inclusive served range), content_offset,
line_range_bytes (total bytes of the line range pre-byte-cap), and
num_lines/num_bytes. The server detects truncation via
content_offset+len(content) < line_range_bytes and prompts the model to
resume from that offset.
A paired server change reads these fields instead of hardcoding
start_line=0/end_line=last.
Adds tests for UTF-8 boundary capping, pagination metadata, and resume.
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.
execViewFile read the whole file and ignored the agent's StartLine/EndLine, so viewing a large file returned its entire content as the tool result -- a ~900KB blob for a 3k-line CSV stalled the following turn.
Implement the Antigravity view_file contract (1-indexed inclusive line range with slice-notation windowing) plus defensive caps:
Adds intArg/intArgOK helpers and tests for windowing, byte cap + offset resume, and range honoring.