You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
read: blank-only text pages are reported as zero lines #60608
A read page containing one blank line is reported to the model as 0 lines. Both an empty file and a selected blank line produce an empty content string, so the serializer cannot distinguish them. This also loses the line number when the page has a continuation offset.
Plugins
None; reproduced with the built-in read filesystem and tool tests.
OpenCode version
Current dev, 2.2.3 source at 8f0fc21e718e8e1ea60aee6ca04875c35cb7a876.
Steps to reproduce
Create a text file with alpha\n\n.
Read it with offset: 2, limit: 1.
The model content says Read file lines.txt, 0 lines.
Expected: Read file lines.txt, lines 2-2 followed by 2: , preserving the selected blank line. A genuinely empty file should still report zero lines.
Four real temporary-file regression cases reproduce this before the fix: an initial blank page, a middle blank page, a final blank page, and a file containing just one newline. No model API calls are needed.
The cause looks like what you describe. The text page joins the selected lines into a single string, so one blank line becomes "", and the serializer treats "" as zero lines. The selected line and its number are dropped, even though the continuation hint still points past that line.
Reproduction script (drive.ts)
// Reproduces anomalyco/opencode#60608: a read page selecting one blank line is reported as "0 lines".import{Effect,Stream}from"effect"import{Llm,OpenCodeDriver}from"opencode-drive"constcases=[{id: "call_middle",file: "middle.txt",offset: 2},// "alpha\n\nbeta\n", line 2 is blank{id: "call_final",file: "lines.txt",offset: 2},// "alpha\n\n", line 2 is blank{id: "call_newline",file: "newline.txt",offset: 1},// "\n", line 1 is blank{id: "call_empty",file: "empty.txt",offset: undefined},// "", genuinely empty]exportdefaultOpenCodeDriver.use({
...(process.env.OC_DEV ? {opencode: {dev: process.env.OC_DEV}} : {}),project: {files: {"middle.txt": "alpha\n\nbeta\n","lines.txt": "alpha\n\n","newline.txt": "\n","empty.txt": "",},},tui: {recording: true},},({ ui, llm })=>Effect.gen(function*(){yield*llm.serve((request)=>{constmessages=(requestasany).body.messagesasArray<{role: string;content: unknown;tool_call_id?: string}>consttools=messages.filter((m)=>m.role==="tool")if(tools.length>0){// Print every read result the model receives.for(constmoftools)console.log(`RESULT ${m.tool_call_id}: ${JSON.stringify(m.content)}`)returnStream.make(Llm.text("done reading"))}if(JSON.stringify(messages).includes("Reply with only the title"))returnStream.make(Llm.text("Read files"))returnStream.make(
...cases.map((c,i)=>Llm.toolCall({index: i,id: c.id,name: "read",input: {path: c.file, ...(c.offset ? {offset: c.offset,limit: 1} : {})},}),),Llm.finish("tool-calls"),)})yield*ui.submit("Read the files")yield*Effect.sleep("8 seconds")yield*ui.screenshot("after")}),)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the clear report. I reproduced this on 2.2.3 and it still happens on the latest
dev(65c0d83).The script below uses a simulated model that calls the built-in
readtool, then prints the tool results returned to the model:alpha\n\nbeta\nwithoffset: 2, limit: 1→Read file middle.txt, 0 linesfollowed by[Output truncated. Continue reading with offset: 3]alpha\n\nwithoffset: 2, limit: 1→Read file lines.txt, 0 lines\nwithoffset: 1, limit: 1→Read file newline.txt, 0 linesRead file empty.txt, 0 lines(correct)The cause looks like what you describe. The text page joins the selected lines into a single string, so one blank line becomes
"", and the serializer treats""as zero lines. The selected line and its number are dropped, even though the continuation hint still points past that line.Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.