fix(discord): retry standalone REST sends on 429 - #88154
Closed
eyeonall wants to merge 1 commit into
Closed
Conversation
Collaborator
Duplicate of #44488, which already implements the same retry_after-aware bounded 429 retry helper for the standalone Discord REST send path. |
Author
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 bounded retry/backoff for Discord standalone REST POSTs so transient 429 rate limits do not immediately abort
hermes send/ cron delivery.This is the same failure mode described in #44468: standalone Discord delivery returns an error on the first 429, and the caller's chunk loop stops there, dropping remaining chunks. The retry now lives inside the Discord standalone adapter, preserving the existing
send_message_tool.pychunk-loop contract: a transient 429 on chunk N can retry and then the loop continues to chunk N+1.Duplicate check note: #44488 is the earlier canonical open PR for #44468. This branch is a current-
mainimplementation and broadens the helper across standalone Discord REST POST sites, including text messages, forum thread creation, caption fallback, and per-file media uploads. If #44488 lands first, this PR can be closed or rebased as a follow-up.Related Issue
Partially addresses #44468
Related / duplicate context: #44488, #44542, #44558
Type of Change
Changes Made
plugins/platforms/discord/adapter.py: add_standalone_post_with_retry()for bounded Discord REST 429 retries.plugins/platforms/discord/adapter.py: honor Discordretry_afterfrom JSON first, thenRetry-After/X-RateLimit-Reset-Afterheaders, then exponential fallback.plugins/platforms/discord/adapter.py: cap long retry waits at 10 seconds so the blocking standalone send path fails fast on long/global limits.plugins/platforms/discord/adapter.py: route standalone text sends, forum JSON thread creation, forum multipart thread creation, caption fallback sends, and per-file media uploads through the helper.tests/tools/test_send_message_tool.py: add focused Discord 429 retry coverage, including body/header retry_after parsing, fallback backoff, exhausted attempts, fail-fast cap, non-429 behavior, and multipart form rebuild.How to Test
uv run pytest tests/tools/test_send_message_tool.py::TestSendDiscord429Retry -quv run pytest tests/tools/test_send_message_tool.py -quv run python -m py_compile plugins/platforms/discord/adapter.py tests/tools/test_send_message_tool.pyuv run ruff check plugins/platforms/discord/adapter.py tests/tools/test_send_message_tool.pyValidated locally on Windows and in the isolated
hermes-stagingLinux account. No production Hermes profile or service was modified.Live Discord smoke validation was also run from
hermes-stagingagainst the configured test channeldiscord:1538734203737477131.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/AScreenshots / Logs
Local:
Staging:
Live Discord smoke: