fix: distinguish transient API errors from billing errors#15109
Open
jwchmodx wants to merge 1 commit intoopenclaw:mainfrom
Open
fix: distinguish transient API errors from billing errors#15109jwchmodx wants to merge 1 commit intoopenclaw:mainfrom
jwchmodx wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Check rate limit and timeout errors before billing errors to avoid showing misleading billing messages for temporary API failures. Fixes openclaw#15055 Changes: - Check isRateLimitErrorMessage() before isBillingErrorMessage() - Check isTimeoutErrorMessage() before isBillingErrorMessage() - Add tests for rate limit (429) and timeout error handling - Ensure transient errors show appropriate retry messages Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-helpers/errors.ts
Line: 528:531
Comment:
**Rate limit misreported**
`sanitizeUserFacingText(..., { errorContext: true })` still rewrites *rate limit* errors to the generic overloaded message via `if (isOverloadedErrorMessage(trimmed) || isRateLimitErrorMessage(trimmed)) return "The AI service is temporarily overloaded...";` (around `ERROR_PREFIX_RE`). Since `sanitizeUserFacingText` is used in user-facing pipelines (e.g. `extractAssistantText` and reply normalization), some surfaces may continue to show the overloaded copy for rate limits, undermining the intent of distinguishing transient failures from other error classes.
How can I resolve this? If you propose a fix, please make it concise. |
bfc1ccb to
f92900f
Compare
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.
Fixes #15055
Summary
Fix error message handling to distinguish between transient API failures (rate limits, timeouts) and actual billing issues.
Problem
Previously, all API failures showed the same billing error message, making it impossible for users to distinguish between:
Changes
isRateLimitErrorMessage()beforeisBillingErrorMessage()isTimeoutErrorMessage()beforeisBillingErrorMessage()Test Results
AI-Assisted Development
This PR was developed with assistance from Claude Opus 4.6. The code has been reviewed and tested to ensure correctness.
Co-Authored-By: Claude Opus 4.6 [email protected]
Greptile Overview
Greptile Summary
This PR updates
formatAssistantErrorTextto classify rate-limit and timeout errors before billing errors, and adds tests to ensure transient errors don’t display the billing/credits messaging.Within the wider codebase, assistant text is also passed through
sanitizeUserFacingText(..., { errorContext: true })in multiple user-facing pipelines (assistant text extraction and reply normalization). That sanitizer still collapses rate-limit errors into the generic “temporarily overloaded” message in itsERROR_PREFIX_RErewrite path, which can negate the PR’s goal on those surfaces.Confidence Score: 4/5
formatAssistantErrorTextis small and well-covered by targeted tests, but another sanitizer used in user-facing flows still rewrites rate-limit errors to the overloaded message, which conflicts with the stated behavior change and can cause incorrect messaging in some surfaces.Last reviewed commit: 7e1df79
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!