优化agent执行命令时tool call的标题显示

This commit is contained in:
xintaofei
2026-03-09 19:53:40 +08:00
parent 33a8d71985
commit 6d86564911

View File

@@ -265,9 +265,8 @@ function buildCommandTerminalOutput(
return isStreaming ? withTrailingNewline(prompt) : prompt
}
const firstNonEmptyLine = terminalOutput
.split("\n")
.find((line) => line.trim().length > 0)
const lines = terminalOutput.split("\n")
const firstNonEmptyLine = lines.find((line) => line.trim().length > 0)
const commandFirstLine = command.split("\n")[0]?.trim() ?? ""
if (firstNonEmptyLine) {
@@ -925,6 +924,10 @@ function deriveToolTitle(
// Command tools
if (name === "bash" || name === "exec_command") {
const description = getField("description")
if (description) {
return ellipsis(description, 80)
}
const direct = getField("command") ?? getField("cmd") ?? getField("script")
const parsedCommand = commandFromUnknownValue(parsed)
const fallback = extractCommandFromUnknownInput(titleSource)