fix(discord): retry standalone send on 429 rate-limit instead of dropping chunks - #44542
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(discord): retry standalone send on 429 rate-limit instead of dropping chunks#44542liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…ping chunks The standalone Discord send path (`_standalone_send`) returned an error dict immediately on 429 responses with no retry. For multi-chunk messages sent via `hermes send`, the chunk loop in `send_message_tool.py` aborts on the first error, silently dropping all remaining chunks. Discord's 429 response includes a `retry_after` field (often sub-second), so a brief wait-and-retry delivers the full message. The live adapter already has retry helpers (`_extract_discord_retry_after`, `_is_discord_rate_limit`), but the standalone path had none. Changes: - `plugins/platforms/discord/adapter.py`: Add `_standalone_parse_retry_after()` helper and retry loop (3 attempts) around both the text POST and per-media POST in `_standalone_send`. Honours Discord's `retry_after` with a 0.5s floor and 10s cap. - `tests/tools/test_send_message_tool.py`: Add `TestStandaloneParseRetryAfter` (5 tests) and `TestSendDiscord429Retry` (4 tests) covering retry-on-429, exhausted retries, missing retry_after, and non-429 error paths.
tonydwb
approved these changes
Jun 12, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Bug Fix - Looks Good
- plugins/platforms/discord/adapter.py — Adds retry logic for 429 rate-limit responses in the standalone send path, using Discord's
retry_afterfield (floored at 0.5s, capped at 10s, max 3 attempts). - Handles 429 for both text messages and media uploads.
- Clean retry-after parsing with proper error handling.
Testing
- tests/tools/test_send_message_tool.py — Comprehensive test coverage:
TestStandaloneParseRetryAfter: 5 tests for the parsing functionTestSendDiscord429Retry: 4 tests for the retry behavior (success, exhausted retries, no retry_after, non-429)
Code Quality
- No security concerns.
- Well-structured retry loop with clear logging.
Reviewed by Hermes Agent
Collaborator
1 task
Contributor
Author
19 tasks
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.
What does this PR do?
Adds 429 rate-limit retry logic to the standalone Discord send path (
_standalone_send), preventing multi-chunk messages from being silently truncated when a rate limit is hit mid-delivery.Related Issue
Fixes #44468
Type of Change
Changes Made
plugins/platforms/discord/adapter.py: Add_standalone_parse_retry_after()helper to extractretry_afterfrom Discord 429 JSON responses. Wrap both the text POST and per-media POST in_standalone_sendwith a retry loop (3 attempts, honouringretry_afterwith 0.5s floor and 10s cap).tests/tools/test_send_message_tool.py: AddTestStandaloneParseRetryAfter(5 unit tests for the parser) andTestSendDiscord429Retry(4 integration tests covering retry-on-429, exhausted retries, missingretry_after, and non-429 error paths).How to Test
pytest tests/tools/test_send_message_tool.py::TestStandaloneParseRetryAfter tests/tools/test_send_message_tool.py::TestSendDiscord429Retry -v— all 9 tests should pass.pytest tests/tools/test_send_message_tool.py -v— all 142 tests should pass (no regressions).pytest tests/e2e/test_discord_adapter.py -v— all 6 tests should pass.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
plugins/platforms/discord/adapter.py::_standalone_send(callers: 1 viastandalone_sender_fnregistry entry, flows:send_message_tool._send_to_platform→entry.standalone_sender_fn)_send_telegram_message_with_retry()and the adapter's_extract_discord_retry_after()/_is_discord_rate_limit()helpers