diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts index fc33463a..7dc41ea5 100644 --- a/packages/opencode/src/tool/read.ts +++ b/packages/opencode/src/tool/read.ts @@ -134,8 +134,14 @@ export const ReadTool = Tool.define("read", { let output = "\n" output += content.join("\n") - if (lines.length > offset + content.length) { - output += `\n\n(File has more lines. Use 'offset' parameter to read beyond line ${offset + content.length})` + const totalLines = lines.length + const lastReadLine = offset + content.length + const hasMoreLines = totalLines > lastReadLine + + if (hasMoreLines) { + output += `\n\n(File has more lines. Use 'offset' parameter to read beyond line ${lastReadLine})` + } else { + output += `\n\n(End of file - total ${totalLines} lines)` } output += "\n"