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:
Peter Steinberger
2026-02-14 16:34:02 +01:00
committed by GitHub
parent aa1dbd34a1
commit 50a6e0e69e
3 changed files with 6 additions and 3 deletions

View File

@@ -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 {