fix(coding-agent): improve read tool description for full file reads
This commit is contained in:
@@ -51,7 +51,7 @@ export function createReadTool(cwd: string, options?: ReadToolOptions): AgentToo
|
|||||||
return {
|
return {
|
||||||
name: "read",
|
name: "read",
|
||||||
label: "read",
|
label: "read",
|
||||||
description: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files.`,
|
description: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,
|
||||||
parameters: readSchema,
|
parameters: readSchema,
|
||||||
execute: async (
|
execute: async (
|
||||||
_toolCallId: string,
|
_toolCallId: string,
|
||||||
@@ -168,9 +168,9 @@ export function createReadTool(cwd: string, options?: ReadToolOptions): AgentToo
|
|||||||
outputText = truncation.content;
|
outputText = truncation.content;
|
||||||
|
|
||||||
if (truncation.truncatedBy === "lines") {
|
if (truncation.truncatedBy === "lines") {
|
||||||
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue]`;
|
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;
|
||||||
} else {
|
} else {
|
||||||
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue]`;
|
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
|
||||||
}
|
}
|
||||||
details = { truncation };
|
details = { truncation };
|
||||||
} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
|
} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
|
||||||
@@ -179,7 +179,7 @@ export function createReadTool(cwd: string, options?: ReadToolOptions): AgentToo
|
|||||||
const nextOffset = startLine + userLimitedLines + 1;
|
const nextOffset = startLine + userLimitedLines + 1;
|
||||||
|
|
||||||
outputText = truncation.content;
|
outputText = truncation.content;
|
||||||
outputText += `\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue]`;
|
outputText += `\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
|
||||||
} else {
|
} else {
|
||||||
// No truncation, no user limit exceeded
|
// No truncation, no user limit exceeded
|
||||||
outputText = truncation.content;
|
outputText = truncation.content;
|
||||||
|
|||||||
Reference in New Issue
Block a user