-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Bug
sanitizeUserFacingText() in pi-embedded-helpers replaces normal assistant responses that discuss billing/pricing topics with the billing error warning message:
⚠️ API provider returned a billing error — your API key has run out of credits or has an insufficient balance...
This happens because isBillingErrorMessage() pattern-matches on content keywords, not just actual API errors.
Steps to Reproduce
- Have a conversation where the assistant discusses pricing, billing, credits, or payment (e.g. "Stripe billing integration", "AI credits per plan")
- The response generates fine and appears correctly on webchat
- On Telegram (and likely other messaging channels), the entire response is replaced with the billing error warning
Root Cause
sanitizeUserFacingText (line ~528 in pi-embedded-helpers) calls isBillingErrorMessage() on the assistant's response text. That function returns true if the text contains "billing" AND any of "upgrade", "credits", "payment", or "plan":
// pi-embedded-helpers, isBillingErrorMessage()
return value.includes("billing") && (
value.includes("upgrade") ||
value.includes("credits") ||
value.includes("payment") ||
value.includes("plan")
);Normal assistant text discussing billing topics triggers this check, and the entire response gets replaced.
Expected Behavior
sanitizeUserFacingText should only apply billing error detection to messages that are already flagged as errors (e.g. stopReason === "error"), not to normal assistant responses.
Suggested Fix
Either:
- Check
stopReason === "error"before applying billing/error pattern detection insanitizeUserFacingText - Only run
isBillingErrorMessageon messages that came from the error handling path, not on all outbound text - Make the pattern matching stricter (e.g. require JSON error payload structure, not just keyword co-occurrence)
Environment
- OpenClaw 2026.2.6-3 (85ed6c7)
- Channel: Telegram
- Model: anthropic/claude-opus-4-6