Skip to content

fix(telegram): reduce false positives billing error detection in conversation text#12946

Merged
gumadeiras merged 2 commits intoopenclaw:mainfrom
jabezborja:patch-3
Feb 10, 2026
Merged

fix(telegram): reduce false positives billing error detection in conversation text#12946
gumadeiras merged 2 commits intoopenclaw:mainfrom
jabezborja:patch-3

Conversation

@jabezborja
Copy link
Contributor

@jabezborja jabezborja commented Feb 9, 2026

Summary

Refines the billing error detection logic to prevent false positives from conversational text (e.g., "billing plan") while ensuring legitimate errors like "insufficient balance" are correctly identified.

Problem

The isBillingErrorMessage function was overly aggressive. It used a fallback check that would flag any message containing the word "billing" along with keywords like "plan", "upgrade", "credits", or "payment" as an error.

This caused legitimate user queries (e.g., "How do I upgrade my billing plan?") to trigger the "API provider returned a billing error" UI, creating a confusing user experience.

⚠️ API provider returned a billing error — your API key has run out of credits or has an insufficient balance. Check your provider's billing dashboard and top up or switch to a different API key.

Solution

  1. Removed Loose Matching: Deleted the broad fallback logic that matched combinations of "billing" + keywords.
  2. Strict Pattern Matching: The function now relies exclusively on matchesErrorPatterns, which checks against a list of specific error strings and regexes.
  3. Enhanced Patterns: Added "insufficient balance" to the ERROR_PATTERNS.billing list to ensure this specific error is still caught explicitly, as it might have been previously caught by the loose check.

Greptile Overview

Greptile Summary

This PR tightens billing error detection in src/agents/pi-embedded-helpers/errors.ts by removing a broad fallback that treated conversational mentions of "billing" + related keywords as an error. isBillingErrorMessage now relies solely on the explicit ERROR_PATTERNS.billing list via matchesErrorPatterns, and the patterns list is extended to include the literal string "insufficient balance" so that common real billing failures are still classified correctly.

This logic feeds into user-facing error rewriting (formatAssistantErrorText / sanitizeUserFacingText) and failover classification (classifyFailoverReason), so reducing false positives here directly prevents the "API provider returned a billing error" UI from triggering on normal user questions.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Change is narrowly scoped to billing error classification, removes an overly broad heuristic that caused known false positives, and keeps detection based on an explicit pattern list (with an added concrete pattern for "insufficient balance"). No other call sites or error formatting paths are modified.
  • src/agents/pi-embedded-helpers/errors.ts

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 9, 2026
@jabezborja
Copy link
Contributor Author

Hello @gumadeiras @thewilloftheshadow @cpojer,

Would appreciate a review when you get a chance.

This issue has been bugging me for quite a while as I've been working a lot with OpenClaw with Billing.

Thank you!

image

@gumadeiras gumadeiras merged commit 8c73dbe into openclaw:main Feb 10, 2026
18 of 19 checks passed
quotentiroler added a commit that referenced this pull request Feb 10, 2026
- Fix code-size -> code-analysis job name (5 jobs had wrong dependency)
- Remove useless install-check job (was no-op)
- Add explicit docs_only guard to release-check
- Remove dead submodule checkout steps (no submodules in repo)
- Rename detect-docs-only -> detect-docs-changes, add docs_changed output
- Reorder check script: format first for faster fail
- Fix billing error test (PR #12946 removed fallback detection but not test)
trevorgordon981 pushed a commit to trevorgordon981/openclaw that referenced this pull request Feb 10, 2026
trevorgordon981 pushed a commit to trevorgordon981/openclaw that referenced this pull request Feb 10, 2026
trevorgordon981 pushed a commit to trevorgordon981/openclaw that referenced this pull request Feb 10, 2026
- Fix code-size -> code-analysis job name (5 jobs had wrong dependency)
- Remove useless install-check job (was no-op)
- Add explicit docs_only guard to release-check
- Remove dead submodule checkout steps (no submodules in repo)
- Rename detect-docs-only -> detect-docs-changes, add docs_changed output
- Reorder check script: format first for faster fail
- Fix billing error test (PR openclaw#12946 removed fallback detection but not test)
lucasmpramos pushed a commit to butley/openclaw that referenced this pull request Feb 10, 2026
lucasmpramos pushed a commit to butley/openclaw that referenced this pull request Feb 10, 2026
- Fix code-size -> code-analysis job name (5 jobs had wrong dependency)
- Remove useless install-check job (was no-op)
- Add explicit docs_only guard to release-check
- Remove dead submodule checkout steps (no submodules in repo)
- Rename detect-docs-only -> detect-docs-changes, add docs_changed output
- Reorder check script: format first for faster fail
- Fix billing error test (PR openclaw#12946 removed fallback detection but not test)
Hansen1018 pushed a commit to Hansen1018/openclaw that referenced this pull request Feb 10, 2026
Hansen1018 pushed a commit to Hansen1018/openclaw that referenced this pull request Feb 10, 2026
- Fix code-size -> code-analysis job name (5 jobs had wrong dependency)
- Remove useless install-check job (was no-op)
- Add explicit docs_only guard to release-check
- Remove dead submodule checkout steps (no submodules in repo)
- Rename detect-docs-only -> detect-docs-changes, add docs_changed output
- Reorder check script: format first for faster fail
- Fix billing error test (PR openclaw#12946 removed fallback detection but not test)
@theSamPadilla
Copy link
Contributor

Screenshot 2026-02-10 at 8 56 34 PM Crazy error lol

skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
- Fix code-size -> code-analysis job name (5 jobs had wrong dependency)
- Remove useless install-check job (was no-op)
- Add explicit docs_only guard to release-check
- Remove dead submodule checkout steps (no submodules in repo)
- Rename detect-docs-only -> detect-docs-changes, add docs_changed output
- Reorder check script: format first for faster fail
- Fix billing error test (PR openclaw#12946 removed fallback detection but not test)
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.

3 participants

Comments