hermes - 💡(How to fix) Fix weixin: ret=-2 errmsg="rate limited" also indicates stale context_token (follow-up to #18100) [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. ret=-2 errmsg="unknown error" — fixed in #17432 ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zX: iLink sendmessage rate limited: ret=-2 errcode=None errmsg=rate limited return msg == "unknown error" return msg in ("unknown error", "rate limited")
  • #17228 — original discovery (errmsg="unknown error")

Root Cause

_is_stale_session_ret() in gateway/platforms/weixin.py checks:

msg = (errmsg or "").strip().lower()
if not msg:
    return True
return msg == "unknown error"

When errmsg is "rate limited", it falls through to the rate-limit backoff path, burning all retries against the dead token.

Fix Action

Fixed

Code Example

WARNING gateway.platforms.weixin: [Weixin] rate limited for o9cq80zX; backing off 3.0s before retry
ERROR   gateway.platforms.weixin: [Weixin] send failed to=o9cq80zX: iLink sendmessage rate limited: ret=-2 errcode=None errmsg=rate limited

---

msg = (errmsg or "").strip().lower()
if not msg:
    return True
return msg == "unknown error"

---

if not msg:
    return True
return msg in ("unknown error", "rate limited")
RAW_BUFFERClick to expand / collapse

Problem

The Weixin adapter's _is_stale_session_ret() helper recognizes two variants of stale context_token:

  1. ret=-2 errmsg="unknown error" — fixed in #17432
  2. ret=-2 errmsg=None/"" — reported in #18100

We encountered a third variant that is also missed:

WARNING gateway.platforms.weixin: [Weixin] rate limited for o9cq80zX; backing off 3.0s before retry
ERROR   gateway.platforms.weixin: [Weixin] send failed to=o9cq80zX: iLink sendmessage rate limited: ret=-2 errcode=None errmsg=rate limited

This is the same stale-session signal — not a genuine rate limit. Recovery pattern is identical: after the user sends an inbound message (which refreshes context_token), subsequent sends succeed immediately.

Root Cause

_is_stale_session_ret() in gateway/platforms/weixin.py checks:

msg = (errmsg or "").strip().lower()
if not msg:
    return True
return msg == "unknown error"

When errmsg is "rate limited", it falls through to the rate-limit backoff path, burning all retries against the dead token.

Proposed Fix

Widen the check to also treat "rate limited" as a stale-session signal:

if not msg:
    return True
return msg in ("unknown error", "rate limited")

Environment

  • Hermes Agent v0.13.0
  • Weixin iLink adapter
  • iLink endpoint: https://ilinkai.weixin.qq.com

References

  • #17228 — original discovery (errmsg="unknown error")
  • #18100 — empty errmsg variant
  • #17432 — merged fix for variant 1

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix weixin: ret=-2 errmsg="rate limited" also indicates stale context_token (follow-up to #18100) [2 pull requests]