diff --git a/packages/coding-agent/src/tools/read.ts b/packages/coding-agent/src/tools/read.ts index 5ad06bc1f..9c8ff85c5 100644 --- a/packages/coding-agent/src/tools/read.ts +++ b/packages/coding-agent/src/tools/read.ts @@ -800,10 +800,7 @@ export class ReadTool implements AgentTool { // context (added below if offset is explicit). const requestedStart = offset ? Math.max(0, offset - 1) : 0; const ignoreResultLimits = options.ignoreResultLimits ?? false; - const requestedEnd = - limit !== undefined && !ignoreResultLimits - ? Math.min(requestedStart + limit, allLines.length) - : allLines.length; + const requestedEnd = limit !== undefined ? Math.min(requestedStart + limit, allLines.length) : allLines.length; // Expand only on sides the user actually constrained: leading context // when offset>1, trailing context when a finite limit was set. const expanded = expandRangeWithContext( @@ -811,7 +808,7 @@ export class ReadTool implements AgentTool { requestedEnd, allLines.length, offset !== undefined && offset > 1, - limit !== undefined && !ignoreResultLimits, + limit !== undefined, ); const startLine = expanded.startLine; const endLineExpanded = expanded.endLine; @@ -842,7 +839,7 @@ export class ReadTool implements AgentTool { const endLine = endLineExpanded; const selectedContent = allLines.slice(startLine, endLine).join("\n"); - const userLimitedLines = limit !== undefined && !ignoreResultLimits ? endLine - startLine : undefined; + const userLimitedLines = limit !== undefined ? endLine - startLine : undefined; const truncation = ignoreResultLimits ? noTruncResult(selectedContent) : truncateHead(selectedContent); const shouldAddHashLines = displayMode.hashLines;