mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:11:26 +00:00
Agents: scope sanitizeUserFacingText rewrites to errorContext
Squash-merge #12988. Refs: #12889 #12309 #3594 #7483 #10094 #10368 #11317 #11359 #11649 #12022 #12432 #12676 #12711
This commit is contained in:
@@ -30,4 +30,14 @@ describe("extractAssistantText", () => {
|
||||
};
|
||||
expect(extractAssistantText(message)).toBe("Hi there");
|
||||
});
|
||||
|
||||
it("rewrites error-ish assistant text only when the transcript marks it as an error", () => {
|
||||
const message = {
|
||||
role: "assistant",
|
||||
stopReason: "error",
|
||||
errorMessage: "500 Internal Server Error",
|
||||
content: [{ type: "text", text: "500 Internal Server Error" }],
|
||||
};
|
||||
expect(extractAssistantText(message)).toBe("HTTP 500: Internal Server Error");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -389,5 +389,10 @@ export function extractAssistantText(message: unknown): string | undefined {
|
||||
}
|
||||
}
|
||||
const joined = chunks.join("").trim();
|
||||
return joined ? sanitizeUserFacingText(joined) : undefined;
|
||||
const stopReason = (message as { stopReason?: unknown }).stopReason;
|
||||
const errorMessage = (message as { errorMessage?: unknown }).errorMessage;
|
||||
const errorContext =
|
||||
stopReason === "error" || (typeof errorMessage === "string" && Boolean(errorMessage.trim()));
|
||||
|
||||
return joined ? sanitizeUserFacingText(joined, { errorContext }) : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user