fix(discord): add retry logic for chunked message sends on rate-limit#32899
fix(discord): add retry logic for chunked message sends on rate-limit#32899kevinWangSheng wants to merge 2 commits intoopenclaw:mainfrom
Conversation
- Add RTL script detection regex for Hebrew and Arabic - Prepend RLM (Right-to-Left Mark, \u200F) to draft text when RTL content detected - Skip RLM when HTML parse mode is used (handles directionality automatically) Fixes openclaw#32852: Telegram draft preview renders LTR for RTL languages
- Add sendWithRetry() wrapper around bot sender path - Retry up to 2 times for 429 and 5xx errors - Support retry-after header for backoff - Fixes issue openclaw#32887
|
🤖 We're reviewing this PR with Aisle We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛ Progress:
Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-03-03T10:38:09Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 965cf31bc1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const draftId = streamDraftId ?? allocateTelegramDraftId(); | ||
| streamDraftId = draftId; | ||
| // Prepend RLM for RTL languages when not using HTML parse mode (which handles directionality automatically) | ||
| const rtlText = renderedParseMode ? renderedText : prependRTLMarkIfNeeded(renderedText); |
There was a problem hiding this comment.
Recheck draft length after prepending RTL mark
The new RTL handling prepends \u200F in draft mode, but the maxChars guard runs earlier against renderedText and does not account for this extra character. For messages already at the configured limit (default 4096) that contain Hebrew/Arabic text, sendMessageDraft is now called with a string length of maxChars + 1, which can trigger Telegram API failures and stop preview streaming unexpectedly for exactly-at-limit RTL content.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR adds retry logic for Discord text chunk sends that encounter 429/5xx rate limits, and prepends RTL marks for Arabic/Hebrew text in Telegram draft-transport previews. Discord changes: The Telegram changes: The RTL fix is well-scoped to draft transport, correctly bypassing HTML parse-mode (which natively handles directionality) and using accurate Unicode ranges for Hebrew and Arabic script detection. Both changes are focused and non-breaking. Confidence Score: 4/5
Last reviewed commit: 965cf31 |
|
Superseded by #33226 (combined Discord chunk ordering + retry fixes). |
Summary
When a long agent response is split into multiple Discord message chunks (>2000 chars), if any chunk hits a 429 rate-limit or 5xx error mid-sequence, the error propagates up and all remaining chunks are silently dropped.
Fix
Add
sendWithRetry()wrapper around the bot sender path with:retry-afterheader supportChanges
src/discord/monitor/reply-delivery.ts: AddedsendWithRetry()function and wrappedsendMessageDiscord()callTesting
Related Issue
Fixes #32887