Repository navigation
fix(wecom): redeliver sends lost in the 846609 reconnect gap - #124
Open
TaoMasterCoder wants to merge 2 commits into
Open
TaoMasterCoder wants to merge 2 commits into
TaoMasterCoder wants to merge 2 commits into
Conversation
added 2 commits
November 29, 2026 09:13
Port of hermes-agent core PR #114751 (closed when the WeCom platform moved out of core). Without it a send rejected with errcode 846609 (subscription lost) during the websocket reconnect gap returned a plain failed SendResult and the message - often a final response - was lost forever. Contract: only provably-undelivered failures (846609 server rejection before enqueue, _require_ws refusal before any frame was written) are transient and retried after the reconnect (bounded, backoff 2s, wait 15s, max 2 retries); ambiguous failures (timeouts, post-write ack drops) keep the original fail-closed / passive->proactive shape and are never retried. Exhausted waits fail closed as send_path_degraded so the core delivery ledger replays them, and a successful _listen_loop reconnect kicks that replay itself since WeCom self-heals in-process (the adapter-swap replay never fires for it). Tests: wecom/tests/test_wecom_redelivery.py (9 new; 9/9 red without the fix, green with it; whole suite 102 passed).
… reconnect kick CI (current core main) has no Platform.WECOM member any more; plugin platforms resolve through Platform(PLATFORM_NAME) via the enum's dynamic _missing_ hook, the same call-time pattern the adapter constructor and yuanbao already use. Platform.WECOM raised AttributeError in _trigger_failed_obligation_redelivery.
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
Port of hermes-agent core PR NousResearch/hermes-agent#114751, closed without merging when the WeCom platform tree was deleted from core. The fix never landed anywhere — this plugin still silently loses sends that race the websocket reconnect gap.
Scenario / bug
_listen_loopreconnects with backoff [2, 5, ...]s. A send rejected during theclosed → reconnect → subscribedgap fails with errcode 846609 (aibot websocket not subscribed) and the old code returned a plain failedSendResult— the payload, often the agent's final response, was lost forever (and stranded asabandonedin the delivery ledger because the raw WeCom error is not on its runtime-redelivery allowlist).Fix (ported hunk-for-hunk onto current
wecom/)_require_wsrefusals (raised before any frame was written) are transient — the same payload is retried after the reconnect (bounded: 2 retries, 15s send-path wait)._fail_all"connection interrupted") may already have delivered — they keep the original fail-closed / passive→proactive-exactly-once shape, so no duplicate payload ever reaches the wire.send_path_degraded+retryable— core's runtime-redelivery token (gateway/delivery_ledger.py_RUNTIME_RETRYABLE_ERRORS) — so the final response is replayed with a visible marker instead of lost._listen_loopnow calls_redeliver_failed_obligations_for_platformdirectly after a successful reconnect (best-effort, ledger failures never break the reconnect path).Tests
wecom/tests/test_wecom_redelivery.py(ported from the core PR): 9 tests covering deliver-exactly-once retry,send_path_degradedfail-closed, reconnect kick, non-transient errcodes, single timeout fallback, and the reviewer's duplicate-send cases on the real_requestpath — 9/9 red without the fix, green with it; whole suite 102 passed. (test_wecom_image_link_fallback.pyfails identically on untouchedmainlocally — unrelated core-version drift.)Related
Supersedes the lost coverage of the three closed core PRs; this is #3 of 3 (stream-tail = #122, inbound video/voice = #123).