Skip to content

fix: remove billing error false-positive from sanitizeUserFacingText#12226

Closed
Yida-Dev wants to merge 1 commit intoopenclaw:mainfrom
Yida-Dev:fix/billing-false-positive-sanitize
Closed

fix: remove billing error false-positive from sanitizeUserFacingText#12226
Yida-Dev wants to merge 1 commit intoopenclaw:mainfrom
Yida-Dev:fix/billing-false-positive-sanitize

Conversation

@Yida-Dev
Copy link
Contributor

@Yida-Dev Yida-Dev commented Feb 9, 2026

Summary

  • sanitizeUserFacingText() runs on all outgoing messages (Telegram, Slack, etc.) and calls isBillingErrorMessage() which false-positive matches common words like "billing plan", "credit balance", "payment" in normal AI responses
  • When triggered, the entire AI response is replaced with the billing error banner — users reported this as a persistent issue on Telegram (Telegram shows billing error while Web UI responses succeed (Claude Max) #11359)
  • Real billing errors are already caught by formatAssistantErrorText() which correctly gates on stopReason === "error" before checking billing patterns (line 331 + 388)
  • The isBillingErrorMessage() check in sanitizeUserFacingText() is redundant and harmful — removed it
  • User @afiffattouh confirmed the root cause analysis and verified the patch works

Test plan

  • Added regression test with 5 false-positive samples ("billing plan", "credit balance", "payment method", etc.)
  • All 11 sanitize tests pass
  • Billing error detection tests still pass (isBillingErrorMessage unchanged)
  • formatAssistantErrorText still catches real billing errors via stopReason === "error" gate

Closes #11359

Co-Authored-By: Claude Opus 4.6 [email protected]

Greptile Overview

Greptile Summary

This change removes the isBillingErrorMessage(trimmed) branch from sanitizeUserFacingText() so that normal assistant responses mentioning billing-related terms (e.g., “billing plan”, “credit balance”, “payment method”) are no longer replaced with the generic billing banner.

Billing error detection remains in formatAssistantErrorText(), which is only used for assistant messages where stopReason === "error" (or an explicit errorMessage), keeping the billing banner behavior scoped to real provider failures. A regression test was added to ensure billing-related words in normal responses are preserved.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are narrowly scoped: removing a redundant billing-error rewrite from sanitizeUserFacingText and adding a regression test. Billing banner behavior remains enforced via formatAssistantErrorText for stopReason==='error'. No behavioral issues found in the modified logic beyond the intended fix.
  • No files require special attention

sanitizeUserFacingText() runs on ALL outgoing messages (Telegram, etc.)
and calls isBillingErrorMessage() which matches common words like
"billing plan", "credit balance", "payment". This causes normal AI
responses discussing billing topics to be replaced with the billing
error banner.

Real billing errors are already caught by formatAssistantErrorText()
which correctly gates on stopReason === "error" before checking billing
patterns. The check in sanitizeUserFacingText is redundant and harmful.

Closes openclaw#11359

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Takhoffman
Copy link
Contributor

Fixed in #12988.

This will go out in the next OpenClaw release.

If you still see this after updating to the first release that includes #12988, please open a new issue with:

  • your OpenClaw version
  • channel (Telegram/Slack/etc)
  • the exact prompt/response that got rewritten
  • whether Web UI showed the full text vs the channel being rewritten
  • relevant logs around send/normalize (if available)

Link back here for context.

@brin-tapcart
Copy link

Manually patched our instance. Seems like its working. Thanks @Yida-Dev

@Takhoffman
Copy link
Contributor

Closing as superseded by the merged sanitize/error-context work:

This PR’s intent appears covered by those merged changes and current mainline tests.

@Takhoffman Takhoffman closed this Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram shows billing error while Web UI responses succeed (Claude Max)

3 participants

Comments