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
Truncate reports one more truncated line than it removed when the output ends in a newline #788
Truncate.output splits on a newline and counts lines from the result. For text that ends in a newline, split("\n") yields a trailing empty string, so a 100-line output becomes 101 elements.
Two visible effects:
The preview keeps that empty string as its last entry.
removed = lines.length - out.length reports 91 for a 100-line file truncated to maxLines: 10, where 90 lines were actually dropped.
The count is how the model reasons about how much output it missed, and it appears alongside "The tool call succeeded but the output was truncated." A file that ends in a newline is the common case (almost every CLI and log file), so the number the model reads is routinely one too high.
It also reads a blank line into the preview, which is what a model takes as "there is an empty line here" when deciding where a log ends.
Reproduction
constlines=Array.from({length: 100},(_,i)=>`line${i}`).join("\n")+"\n"constresult=awaitTruncate.output(lines,{maxLines: 10})result.content// contains "...91 lines truncated...", should be 90
The existing truncates by line count test uses the same 100 lines without the trailing newline, which is why this was not caught.
Activity