hermes - 💡(How to fix) Fix fix(weixin): MEDIA tag leaks for .md/.json/.yaml/.toml/.log files + no retry on session expiry [3 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…

Two related bugs in the WeChat (weixin) message delivery path that affect file sending reliability:

Error Message

When the iLink session expires (e.g., after gateway restart), send_weixin_direct() calls adapter.send() which internally exhausts _send_text_chunk retries and returns an error. The function then immediately returns this error with no retry at the send_weixin_direct level — no context_token refresh, no backoff, no tokenless fallback. 4. Immediately try to send a message — observe ret=-2 error with no retry

Root Cause

After gateway restart, the stored context_token is stale. The adapter's internal _send_text_chunk retries handle errcode: -14 (session timeout) correctly, but ret: -2 (rate limit, often caused by stale session) is treated as a pure rate limit with insufficient backoff.

Fix Action

Fixed

Code Example

\.(?:png|jpe?g|gif|webp|mp4|mov|avi|mkv|webm|ogg|opus|mp3|wav|m4a|flac|epub|pdf|zip|rar|7z|docx?|xlsx?|pptx?|txt|csv|apk|ipa)
RAW_BUFFERClick to expand / collapse

Summary

Two related bugs in the WeChat (weixin) message delivery path that affect file sending reliability:

Bug 1: MEDIA tag leaks as raw text for common file types

BasePlatformAdapter.extract_media() in gateway/platforms/base.py uses a regex whitelist of file extensions. The whitelist is missing several common types: .md, .json, .yaml, .yml, .toml, .log. When a MEDIA:/path/to/file.md tag is used, the regex does not match → the MEDIA tag stays in the text and appears as raw text on WeChat instead of being converted to a file attachment.

Current regex (line 2162):

\.(?:png|jpe?g|gif|webp|mp4|mov|avi|mkv|webm|ogg|opus|mp3|wav|m4a|flac|epub|pdf|zip|rar|7z|docx?|xlsx?|pptx?|txt|csv|apk|ipa)

Fix: Add |md|json|yaml|yml|toml|log to the whitelist.

Bug 2: send_weixin_direct() returns immediately on rate-limit/session errors

When the iLink session expires (e.g., after gateway restart), send_weixin_direct() calls adapter.send() which internally exhausts _send_text_chunk retries and returns an error. The function then immediately returns this error with no retry at the send_weixin_direct level — no context_token refresh, no backoff, no tokenless fallback.

After gateway restart, the stored context_token is stale. The adapter's internal _send_text_chunk retries handle errcode: -14 (session timeout) correctly, but ret: -2 (rate limit, often caused by stale session) is treated as a pure rate limit with insufficient backoff.

Suggested fix: Add a retry loop in the fallback path of send_weixin_direct() that clears the stale context_token and retries at least once.

Steps to Reproduce

  1. Send a message with MEDIA:/tmp/test.md via send_message(target="weixin")
  2. Observe that WeChat shows the raw MEDIA:/tmp/test.md text instead of a file attachment
  3. Restart the Hermes gateway
  4. Immediately try to send a message — observe ret=-2 error with no retry

Environment

  • Hermes Agent: latest
  • Platform: WeChat iLink API
  • OS: macOS

Files Affected

  • gateway/platforms/base.pyextract_media() regex pattern
  • gateway/platforms/weixin.pysend_weixin_direct() fallback path

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