fix: remove false-positive billing error rewrite on normal assistant text (openclaw#17834) thanks @niceysam

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: niceysam <256747835+niceysam@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
niceysam
2026-02-22 03:17:39 +09:00
committed by GitHub
parent 57fbbaebca
commit 5e423b596c
3 changed files with 8 additions and 21 deletions

View File

@@ -244,18 +244,6 @@ function shouldRewriteContextOverflowText(raw: string): boolean {
);
}
function shouldRewriteBillingText(raw: string): boolean {
if (!isBillingErrorMessage(raw)) {
return false;
}
return (
isRawApiErrorPayload(raw) ||
isLikelyHttpErrorText(raw) ||
ERROR_PREFIX_RE.test(raw) ||
BILLING_ERROR_HEAD_RE.test(raw)
);
}
type ErrorPayload = Record<string, unknown>;
function isErrorPayloadObject(payload: unknown): payload is ErrorPayload {
@@ -552,13 +540,6 @@ export function sanitizeUserFacingText(text: string, opts?: { errorContext?: boo
}
}
// Preserve legacy behavior for explicit billing-head text outside known
// error contexts (e.g., "billing: please upgrade your plan"), while
// keeping conversational billing mentions untouched.
if (shouldRewriteBillingText(trimmed)) {
return BILLING_ERROR_USER_MESSAGE;
}
// 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)+/, "");