fix(coding-agent): honor caller-supplied read selector limit
The ignoreResultLimits flag now gates only the byte-budget tail-truncate, never the explicit line window. Reads of internal URLs (skill, local, memory) with a line range previously returned the tail of the file instead of the requested window for files larger than the byte budget.
This commit is contained in:
@@ -800,10 +800,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
|
||||
// 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<typeof readSchema, ReadToolDetails> {
|
||||
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<typeof readSchema, ReadToolDetails> {
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user