Repository navigation
Description
Description
The Read tool's limit schema says it defaults to and is capped at 2,000 lines, but a file under 50 KiB bypasses the limit if limit and offset are omitted. Supplying limit: 2000 for the same file correctly truncates it. The default call can send more lines to the model than the advertised limit and provides no continuation hint.
Reproduction
From packages/core on dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373:
bun -e 'import { Environment } from "@opencode/core/environment/index"; import { AbsolutePath } from "@opencode/core/schema"; import { ReadToolFileSystem } from "@opencode/core/tool/read-filesystem"; import { ReadTool } from "@opencode/core/tool/plugin/read"; import { CrossSpawnSpawner } from "@opencode/util/cross-spawn-spawner"; import { LayerNodePlatform } from "@opencode/util/effect/app-node-platform"; import { LayerNode } from "@opencode/util/effect/layer-node"; import { Effect } from "effect"; import { ChildProcessSpawner } from "effect/process"; const p="/tmp/opencode-many-lines.txt"; await Bun.write(p,"x\n".repeat(3000)); const run=Effect.gen(function*(){const spawner=yield* ChildProcessSpawner.ChildProcessSpawner; const files=Environment.makeFiles(Environment.makeLocalDriver(spawner)); for(const page of [{},{limit:2000}]){const result=yield* ReadToolFileSystem.read(files,AbsolutePath.make(p),"many.txt",page); const output=ReadTool.toModelContent("many.txt",undefined,result); console.log(JSON.stringify({page,type:result.type,header:output.split("\n")[0],truncated:result.truncated,tail:output.split("\n").at(-1)}));}}); await Effect.runPromise(run.pipe(Effect.provide(LayerNode.compile(LayerNode.group([CrossSpawnSpawner.node,LayerNodePlatform.filesystem])))));'Actual:
{"page":{},"type":"file","header":"Read file many.txt, lines 1-3000","tail":"3000: x"}
{"page":{"limit":2000},"type":"text-page","header":"Read file many.txt, lines 1-2000","truncated":true,"tail":"[Output truncated. Continue reading with offset: 2001]"}Expected: both calls honor the default 2,000-line limit and provide a continuation offset. The reproduction uses the real local filesystem driver and the real tool output formatter. read-filesystem.ts chooses the whole-file path based on file size and whether pagination arguments are supplied, without checking line count. The source matches the upstream dev blob.
Activity
opencodejr commentedon Oct 29, 2026
Thanks for the clear reproduction. I can confirm it: I ran your approach in
packages/corewith the local filesystem driver and the Read tool's formatter. On a 3,000-line file of about 6 KB, a call withoutoffset/limitreturns all 3,000 lines as a wholefileresult with no continuation hint. The same call withlimit: 2000stops at line 2,000 and says to continue from offset 2001. The script below reproduces it.This still happens on the latest
dev(d3ad3da9). The relevant code is the same as at your commit: the whole-file shortcut inread-filesystem.tschecks only the 50 KiB size limit and whether pagination arguments were passed, not the 2,000-line limit.Reproduction script (repro.ts)
Run it:
bun repro.ts