Agents: guard billing error detection with length check (#11649)#11680
Closed
lailoo wants to merge 1 commit intoopenclaw:mainfrom
Closed
Agents: guard billing error detection with length check (#11649)#11680lailoo wants to merge 1 commit intoopenclaw:mainfrom
lailoo wants to merge 1 commit intoopenclaw:mainfrom
Conversation
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:
Link back here for context. |
bfc1ccb to
f92900f
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11649
sanitizeUserFacingText()runsisBillingErrorMessage()against all assistant reply text, not just error payloads. When the assistant naturally discusses billing, credits, or payment topics, the sanitizer false-positives and replaces the entire reply with the canned billing error message.Root Cause
isBillingErrorMessage()matches broadly on keyword combinations (e.g. "billing" + "credits"/"payment"/"plan"). This is correct for short API error messages, but false-positives on normal assistant replies that happen to discuss those topics.Fix
Add a length guard (
trimmed.length < 500) before theisBillingErrorMessagecheck insanitizeUserFacingText. Real API billing errors are short error strings (<500 chars). Normal assistant replies discussing billing topics are longer and should pass through unchanged.This is the same pattern already used for context overflow detection (
shouldRewriteContextOverflowTexthas conversational-length guards).Changes
src/agents/pi-embedded-helpers/errors.ts: Addtrimmed.length < 500guard (1 line)CHANGELOG.md: Add entryVerification
Bug reproduced on
mainbranch ❌A 618-char assistant reply discussing billing/credits/payment was entirely replaced with the canned billing error string.
Fix verified on feature branch ✅
Unit tests ✅
Lint ✅