# INFRA-002: OpenClaw Billing Error Filter Rewrites Messages

**Status:** done
**Priority:** P2
**Assignee:** Ben (benjude._.)
**Product:** infra
**Created:** 2026-02-13
**Closed:** 2026-02-13
**Reporter:** Antonio

## Description

OpenClaw's harness has a naive substring filter that rewrites any assistant response containing certain phrases into a canned "billing error" message. This caused confusion when legitimate messages were being replaced.

**Canned replacement message:**
> ⚠️ 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.

## Root Cause

The filter uses `.contains()` substring matching — no escaping, quotes, code blocks, or context awareness. If ANY of these substrings appear in the response, the entire message is replaced:

- `402`
- `payment required`
- `insufficient credits`
- `credit balance`
- `plans & billing`
- `billing` + (`upgrade` | `credits` | `payment` | `plan`)

## Resolution

**Workaround implemented:** ARIA now uses alternative vocabulary when discussing financial/subscription topics:
- invoicing, account settings, subscription management
- transaction, purchase, checkout
- tokens, quota, units, allocation
- level up, switch tiers, unlock premium

**Configuration:** Checked OpenClaw config and docs — NO config option exists to disable this filter. It's hardcoded in the runtime (`isBillingErrorMessage` function).

**Documentation:** Added to `memory/2026-02-13.md` for future reference.

## Future Consideration

Could file a feature request with OpenClaw team for:
- Config flag to disable the filter (e.g., `messages.suppressBillingRewrite: true`)
- Or smarter context-aware detection vs naive substring matching
