Skip to content

[Bug]: hermes send to Discord drops remaining chunks on a 429 — no retry in the standalone send path (Telegram has one) #44468

Open

Description

@thorawr

Bug Description

hermes send --to discord:... does not retry on Discord 429 rate limits. For a multi-chunk message, the first chunk that hits a 429 aborts the loop and every remaining chunk is silently dropped. Discord's 429 response includes retry_after (often sub-second), so a trivial wait-and-retry would deliver the full message.

Telegram already has exactly this: _send_telegram_message_with_retry() in tools/send_message_tool.py (3 attempts, honors retry_after, exponential backoff via _retry_delay_for_exception). Discord has no equivalent in either layer it passes through.

Where (verified on v0.16.0 and current main):

  1. tools/send_message_tool.py, the Platform.DISCORD chunk loop: calls entry.standalone_sender_fn(...) per chunk and return result on the first chunk whose result dict has an error — no retry, and the remaining chunks are never sent.
  2. plugins/platforms/discord/adapter.py, _standalone_send(): raw aiohttp POSTs; a 429 becomes {"error": "Discord API error (429): ..."} with no retry. (The 429 helpers elsewhere in that file — _extract_discord_retry_after, _is_discord_rate_limit — serve the live gateway adapter and slash-command sync, not the standalone path.)

Workaround: we now chunk in our own wrapper and call hermes send --json once per chunk with per-chunk retry/verification, but native retry would fix every hermes send consumer.

Steps to Reproduce

  1. Set up multiple bot identities posting to the same Discord channel.
  2. From concurrent hermes send processes, post several multi-chunk (>2000 char) messages to that channel in quick succession.
  3. One process hits 429 You are being rate limited, retry_after: 0.3 mid-stream.
  4. Its trailing chunks are silently dropped — the chunk loop returns on the first error.

Observed in production 2026-06-10: an 8-chunk message lost chunks 7–8 to a 429 with retry_after: 0.3 — a 0.3-second wait would have saved the delivery.

Expected Behavior

On a 429, honor retry_after (with a small cap and bounded attempts), retry the failed chunk, then continue with the remaining chunks — parity with the Telegram path, wrapping the Discord chunk send in the same retry helper pattern.

Environment: hermes-agent v0.16.0 (2026.6.5), Pop!_OS 24.04, Python 3.11.15. Also confirmed present in main as of 2026-06-11 (same code in both files).

Actual Behavior

The first chunk that hits a 429 returns {"error": "Discord API error (429): You are being rate limited, retry_after: 0.3"} and the chunk loop exits — all remaining chunks are silently dropped with no retry. Observed 2026-06-10: an 8-chunk message delivered chunks 1–6 and lost 7–8 to a single sub-second 429.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

No response

Debug Report

Debug share omitted — exact root cause, file paths, and code locations are identified in the Description and Root Cause sections below (verified in both v0.16.0 and current main), so a log/config dump shouldn't be needed. Happy to provide targeted log excerpts on request.

Operating System

Pop!_OS 24.04

Python Version

3.11.15

Hermes Version

0.16.0 (2026.6.5)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

  1. tools/send_message_tool.py, Platform.DISCORD chunk loop: calls entry.standalone_sender_fn(...) per chunk and does return result on the first chunk whose result dict has an error — no retry, remaining chunks never sent.
  2. plugins/platforms/discord/adapter.py, _standalone_send(): raw aiohttp POSTs; a 429 becomes an error dict with no retry. The existing 429 helpers in that file (_extract_discord_retry_after, _is_discord_rate_limit) serve the live gateway adapter and slash-command sync, not the standalone path.

Proposed Fix (optional)

Wrap the Discord standalone chunk send in the same retry pattern Telegram already uses (_send_telegram_message_with_retry() — 3 attempts, honors retry_after, exponential backoff). On 429: wait retry_after (with a small cap and bounded attempts), retry the failed chunk, continue with remaining chunks.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Activity

  1. AIalliAI commented on Jun 11, 2026

    @AIalliAI

    Verified on current main (6c752ca) — everything in this report checks out:

    1. tools/send_message_tool.py, Platform.DISCORD chunk loop: return result on the first chunk whose result dict has error — no retry, remaining chunks silently dropped. ✔️
    2. plugins/platforms/discord/adapter.py::_standalone_send: raw aiohttp POSTs; any non-2xx (including 429) becomes {"error": "Discord API error (429): ..."} with no retry. ✔️
    3. Telegram parity claim is accurate: the Telegram chunk path retries via _send_telegram_message_with_retry (3 attempts, honors retry_after, exponential backoff). One tiny naming nit: the delay helper is _telegram_retry_delay, not _retry_delay_for_exception. ✔️
    4. The existing 429 helpers in the adapter (_extract_discord_retry_after, _is_discord_rate_limit) indeed only serve the live gateway adapter / slash-command sync, not the standalone path. ✔️

    Fix is up in #44488: a bounded-retry POST helper (_standalone_post_with_retry) inside _standalone_send — 3 attempts, retry_after parsed from the 429 JSON body (sub-second precision, so your retry_after: 0.3 case waits 0.3s) with header fallback and exponential backoff, capped at 10s (a longer/global rate limit fails fast rather than stalling the blocking CLI call). Applied to the text-message POST and both forum thread-creation POSTs.

    Putting the retry inside _standalone_send (matching where Telegram retries, inside _send_telegram) means the chunk loop needs no change: a transient 429 on chunk N retries and succeeds, and the remaining chunks proceed. Error dict shapes are unchanged for anything that still fails after retries.

  2. added
    type/bugSomething isn't working
    comp/gatewayGateway runner, session dispatch, delivery
    P2Medium — degraded but workaround exists
    on Jun 11, 2026
  3. liuhao1024 commented on Jun 12, 2026

    @liuhao1024

    This is fixed by #44542 — retries standalone Discord send on 429 rate-limit instead of dropping chunks.

  4. added a commit that references this issue on Jul 11, 2026
    80c971f
  5. GottZ commented on Jul 28, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    Three PRs address #44468 by adding bounded retries around Discord standalone delivery: #44488 retries adapter-level text and forum-thread POSTs, #44542 retries adapter-level text and per-file media POSTs, and #44558 retries each chunk at the send-message-tool layer. All three prevent a transient 429 from immediately aborting the reported multi-chunk text path, but their coverage and retry semantics differ.

    Related pull requests

    Duplicates

    #44542 and #44558 substantially duplicate #44488's fix for Discord 429s dropping trailing chunks, although #44542 implements adapter-level text/media retries and #44558 implements tool-level per-chunk retries.

    Suggested consolidation

    Merge #44488 as the verified best fix and earliest canonical implementation: it directly repairs the reported standalone text path, has focused retry tests, and has a keep_open review with no blocking defects. Keep #44542 and #44558 closed as duplicates; #44542's APPROVED review supports its correctness but does not outweigh the contributor-documented duplication, while #44558 is the less-tested higher-layer alternative.

    Complex graph

    flowchart LR
        classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
        classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
        classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
        classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
        classDef best stroke-width:3px,stroke:#b45309
        classDef target stroke-width:3px,stroke:#4338ca
        I44468(["issue #44468 (open)"])
        subgraph Dup44488 ["PRs duplicating each other"]
            P44488["PR #44488 (open)"]
            P44542["PR #44542 (closed)"]
            P44558["PR #44558 (closed)"]
        end
        P44488 -->|best fix| I44468
        P44542 -->|fixes| I44468
        P44558 -->|fixes| I44468
        class I44468 open
        class I44468 target
        class P44488 open
        class P44542 closed
        class P44558 closed
        class P44488 best
        click I44468 "https://github.com/NousResearch/hermes-agent/issues/44468"
        click P44488 "https://github.com/NousResearch/hermes-agent/pull/44488"
        click P44542 "https://github.com/NousResearch/hermes-agent/pull/44542"
        click P44558 "https://github.com/NousResearch/hermes-agent/pull/44558"
    
    Loading

    Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

    Cross-PR triage: Reviewed 3 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 29 kB of PR diffs, 10 kB of issue/PR text, 6 kB of discussion (10 comments), 7 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/discordDiscord bot adaptertype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions