Skip to content

Commit 9bd0b9f

Browse files
CL-8979: page large read_file responses through to the end (#1180)
* test(read-file): prove large-file paging reaches the end Deep pages past the scan ceiling, path+offset chains, blob resume without re-scan, overlong-line windowing, truncation pass-through, loop-detector and registry pins. All five paging tests fail before the fix; pins hold. * feat(read-file): page large read_file responses through to the end Large-file pages used to dead-end: the scan ceiling fired while unread content remained, overlong lines were grep-only, and the 10k re-cut mangled footer-bearing pages. Resume now seeks to the stored point, pages carry both offset and cursor continuations, and footer-bearing pages pass the truncation layer untouched. * style(read-file): format paging green and its tests * refactor(read-file): resume large reads by same-path offset only Drop the dual footer and live-cursor reuse so continuation is a single stateless path+offset notice, matching the single-way resume direction. Pre-existing cursor tests become same-URI+offset chains; the truncation 10k exemption keys on the offset footer only. Paging mechanics untouched. * fix(read-file): window scan-capped lines so no tail is silently lost A single line past the 8MB scan ceiling was truncated to 2000 chars under a continuation footer whose offset skipped the unshown middle. The scan-capped remainder is now windowed like smaller overlong lines, so every scanned byte reassembles through offset continuation. * test(subagent): drop stop test that cannot tell paging from a loop evaluateSubAgentStop returns null on any tool turn, so the chunked-reads case pinned nothing. Chunk keying stays covered in thrash.test.ts and null-on-tools in the keeps-running test. * fix(read-file): keep Use offset= through the reactor 10k cap Footer-bearing read_file pages already skip the leisure 10k cut so the 50KB page and its continuation footer reach the reactor. The always-on size-cap then sliced the first 10k of the body and dropped Use offset=. Skip that cap for the same pages leisure skips. Dead offsets on files larger than the 8MB scan ceiling now report beyond-EOF with the path and valid range. Skip bytes still do not count against the scan ceiling.
1 parent eb12f0a commit 9bd0b9f

9 files changed

Lines changed: 516 additions & 23 deletions

File tree

‎src/agent/posix-tool-plugins.test.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ describe("buildCorePosixToolPlugins", () => {
119119
new AbortController().signal,
120120
);
121121
expect(allowed.isError).not.toBe(true);
122-
// The read-file guard caps the read before result-truncation would run,
123-
// so a 90KB single line comes back line-truncated and bounded.
124-
expect(String(allowed.content)).toContain("line truncated at 2000 chars");
125-
expect(Buffer.byteLength(String(allowed.content), "utf8")).toBeLessThan(
126-
4096,
127-
);
122+
// The read-file guard windows the overlong line into a bounded page, so
123+
// a 90KB single line comes back pageable: the tail stays reachable by
124+
// path+offset continuation, not only by grep.
125+
expect(String(allowed.content)).not.toContain("line truncated");
126+
expect(String(allowed.content)).toContain("to continue");
127+
expect(
128+
Buffer.byteLength(String(allowed.content), "utf8"),
129+
).toBeLessThanOrEqual(50 * 1024);
128130
} finally {
129131
await rm(cwd, { recursive: true, force: true });
130132
}

0 commit comments

Comments
 (0)