Return user-facing message if API reuturn 429 API rate limit reached #2202 (#10415)

* Return user-facing message if API reuturn 429 API rate limit reached

* clarify the error message

* fix(agents): improve 429 user messaging (#10415) (thanks @vincenthsin)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Vincent
2026-02-15 00:40:02 +08:00
committed by GitHub
parent ff32f43459
commit 478af81706
10 changed files with 115 additions and 14 deletions

View File

@@ -60,6 +60,12 @@ describe("sanitizeUserFacingText", () => {
);
});
it("returns a friendly message for rate limit errors in Error: prefixed payloads", () => {
expect(sanitizeUserFacingText("Error: 429 Rate limit exceeded", { errorContext: true })).toBe(
"⚠️ API rate limit reached. Please try again later.",
);
});
it("collapses consecutive duplicate paragraphs", () => {
const text = "Hello there!\n\nHello there!";
expect(sanitizeUserFacingText(text)).toBe("Hello there!");