#20982: Improve 429 messaging for Retry-After parse failures and failover
commands
agents
size: S
Cluster:
Error Resilience and Retry Logic
## Summary
- update rate-limit user-facing copy to explicitly mention failover behavior
- parse Retry-After hints from provider error payloads/messages when present
- report an explicit parse-failure message when Retry-After cannot be extracted
- add tests for both parse-success and parse-failure 429 paths
## Why
When Anthropic/OpenClaw hits a 429, operators need clear messaging about:
- how long to wait (when available)
- whether failover is happening
- when Retry-After parsing failed
## Validation
- ran:
RUN v4.0.18 /Users/tsopic/openclaw
✓ src/agents/pi-embedded-helpers.formatassistanterrortext.e2e.test.ts (20 tests) 5ms
Test Files 1 passed (1)
Tests 20 passed (20)
Start at 16:24:13
Duration 1.29s (transform 650ms, setup 83ms, import 1.12s, tests 5ms, environment 9ms)
- result: 20 passed
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Enhances 429 rate-limit error messaging by parsing `Retry-After` hints from provider error payloads and providing explicit feedback about failover behavior. The implementation adds a new `extractRetryAfterLabel` function that parses retry hints from JSON fields (`retry_after`, `retry_after_ms`) and natural language patterns in error messages. When a retry hint is successfully parsed, users see "Retry after about Xs" messaging; when parsing fails, they get an explicit "Failed to parse Retry-After" message. Both cases mention failover engagement.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk
- The changes improve user-facing error messaging without affecting core logic. The new `extractRetryAfterLabel` function uses defensive parsing with proper null checks and finite number validation. Test coverage includes both success and failure paths for the new parsing logic. The implementation follows the repository's coding style and has thorough error handling.
- No files require special attention
<sub>Last reviewed commit: 77b2758</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23497: feat(retry): add retryHttpAsync utility with comprehensive coverage
by thinstripe · 2026-02-22
78.5%
#9482: feat: add cloud code assist retry logic and parsing for rate limit ...
by mrcha033 · 2026-02-05
76.8%
#9173: Fix: Improve error messaging for API rate limits and billing errors
by vishaltandale00 · 2026-02-04
75.0%
#16239: fix: retry on transient API errors (overloaded, rate-limit, timeout)
by zerone0x · 2026-02-14
74.7%
#10551: feat(infra): add error classification for smarter retry decisions
by DukeDeSouth · 2026-02-06
74.7%
#12314: fix: treat HTTP 5xx server errors as failover-worthy
by hsssgdtc · 2026-02-09
73.7%
#10367: CLI/Ops: resilient browser fill + failover hardening + operations t...
by cluster2600 · 2026-02-06
73.5%
#11821: fix(auth): trigger failover on 401 status code from expired OAuth t...
by AnonO6 · 2026-02-08
73.2%
#15050: fix: transcript corruption resilience — strip aborted tool_use bloc...
by yashchitneni · 2026-02-12
72.7%
#15109: fix: distinguish transient API errors from billing errors
by jwchmodx · 2026-02-13
72.6%