mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 20:41:24 +00:00
fix: strip leading empty lines in sanitizeUserFacingText (#16280)
* fix: strip leading empty lines in sanitizeUserFacingText (#16158) (thanks @mcinteerj) * fix: strip leading empty lines in sanitizeUserFacingText (#16158) (thanks @mcinteerj) * fix: strip leading empty lines in sanitizeUserFacingText (#16158) (thanks @mcinteerj)
This commit is contained in:
committed by
GitHub
parent
aa1dbd34a1
commit
50a6e0e69e
@@ -77,7 +77,7 @@ describe("sanitizeUserFacingText", () => {
|
||||
});
|
||||
|
||||
it("strips leading whitespace and newlines combined", () => {
|
||||
expect(sanitizeUserFacingText("\n \n Hello")).toBe("Hello");
|
||||
expect(sanitizeUserFacingText("\n \nHello")).toBe("Hello");
|
||||
expect(sanitizeUserFacingText(" \n\nHello")).toBe("Hello");
|
||||
});
|
||||
|
||||
|
||||
@@ -527,7 +527,10 @@ export function sanitizeUserFacingText(text: string, opts?: { errorContext?: boo
|
||||
}
|
||||
}
|
||||
|
||||
return collapseConsecutiveDuplicateBlocks(stripped).trimStart();
|
||||
// Strip leading blank lines (including whitespace-only lines) without clobbering indentation on
|
||||
// the first content line (e.g. markdown/code blocks).
|
||||
const withoutLeadingEmptyLines = stripped.replace(/^(?:[ \t]*\r?\n)+/, "");
|
||||
return collapseConsecutiveDuplicateBlocks(withoutLeadingEmptyLines);
|
||||
}
|
||||
|
||||
export function isRateLimitAssistantError(msg: AssistantMessage | undefined): boolean {
|
||||
|
||||
Reference in New Issue
Block a user