tweak: tool outputs to be more llm friendly (#13269)

This commit is contained in:
Aiden Cline
2026-02-12 00:33:18 -06:00
committed by GitHub
parent d86f24b6b3
commit 624dd94b5d
3 changed files with 15 additions and 10 deletions

View File

@@ -109,7 +109,8 @@ export const GrepTool = Tool.define("grep", {
}
}
const outputLines = [`Found ${finalMatches.length} matches`]
const totalMatches = matches.length
const outputLines = [`Found ${totalMatches} matches${truncated ? ` (showing first ${limit})` : ""}`]
let currentFile = ""
for (const match of finalMatches) {
@@ -127,7 +128,9 @@ export const GrepTool = Tool.define("grep", {
if (truncated) {
outputLines.push("")
outputLines.push("(Results are truncated. Consider using a more specific path or pattern.)")
outputLines.push(
`(Results truncated: showing ${limit} of ${totalMatches} matches (${totalMatches - limit} hidden). Consider using a more specific path or pattern.)`,
)
}
if (hasErrors) {
@@ -138,7 +141,7 @@ export const GrepTool = Tool.define("grep", {
return {
title: params.pattern,
metadata: {
matches: finalMatches.length,
matches: totalMatches,
truncated,
},
output: outputLines.join("\n"),