mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:28:26 +00:00
refactor(agents): dedupe subagent inline text extraction
This commit is contained in:
@@ -118,6 +118,19 @@ function extractToolResultText(content: unknown): string {
|
|||||||
return joined?.trim() ?? "";
|
return joined?.trim() ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractInlineTextContent(content: unknown): string {
|
||||||
|
if (!Array.isArray(content)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
extractTextFromChatContent(content, {
|
||||||
|
sanitizeText: sanitizeTextContent,
|
||||||
|
normalizeText: (text) => text.trim(),
|
||||||
|
joinWith: "",
|
||||||
|
}) ?? ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function extractSubagentOutputText(message: unknown): string {
|
function extractSubagentOutputText(message: unknown): string {
|
||||||
if (!message || typeof message !== "object") {
|
if (!message || typeof message !== "object") {
|
||||||
return "";
|
return "";
|
||||||
@@ -133,13 +146,7 @@ function extractSubagentOutputText(message: unknown): string {
|
|||||||
return sanitizeTextContent(content);
|
return sanitizeTextContent(content);
|
||||||
}
|
}
|
||||||
if (Array.isArray(content)) {
|
if (Array.isArray(content)) {
|
||||||
return (
|
return extractInlineTextContent(content);
|
||||||
extractTextFromChatContent(content, {
|
|
||||||
sanitizeText: sanitizeTextContent,
|
|
||||||
normalizeText: (text) => text.trim(),
|
|
||||||
joinWith: "",
|
|
||||||
}) ?? ""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -150,13 +157,7 @@ function extractSubagentOutputText(message: unknown): string {
|
|||||||
return sanitizeTextContent(content);
|
return sanitizeTextContent(content);
|
||||||
}
|
}
|
||||||
if (Array.isArray(content)) {
|
if (Array.isArray(content)) {
|
||||||
return (
|
return extractInlineTextContent(content);
|
||||||
extractTextFromChatContent(content, {
|
|
||||||
sanitizeText: sanitizeTextContent,
|
|
||||||
normalizeText: (text) => text.trim(),
|
|
||||||
joinWith: "",
|
|
||||||
}) ?? ""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user