hermes - 💡(How to fix) Fix Weixin send_message fails with session timeout due to process isolation [1 participants]

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…
GitHub stats
NousResearch/hermes-agent#14452Fetched 2026-04-24 06:17:10
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4subscribed ×1unsubscribed ×1

Root Cause

The Gateway process and the CLI agent process are separate Python processes that do not share memory state:

  • Gateway: _LIVE_ADAPTERS dict contains the active Weixin connection with valid session context
  • CLI agent: _LIVE_ADAPTERS dict is empty — each new process creates its own adapter instance without the valid session

When send_message is called, it runs in the CLI agent process, creates a brand-new WeixinAdapter instance, and attempts to send via the raw iLink API without the valid session context that the Gateway has already established.

Code Example

if platform == Platform.WEIXIN:
    return await _send_weixin(pconfig, chat_id, message, media_files=media_files)

---

live_adapter = _LIVE_ADAPTERS.get(resolved_token)
if live_adapter is not None and send_session is not None and not send_session.closed:
    # Uses the live adapter's established session
    ...
else:
    # Falls back to creating a new adapter with a fresh connection
    async with aiohttp.ClientSession() as session:
        adapter = WeixinAdapter(...)
        # New connection, no valid session context
RAW_BUFFERClick to expand / collapse

Problem

The send_message tool supports Weixin (platform_map contains "weixin"), but sending messages to Weixin fails with session timeout errors (errcode=-14) when called from the CLI agent, even though the Gateway process has an active Weixin connection.

Root Cause

The Gateway process and the CLI agent process are separate Python processes that do not share memory state:

  • Gateway: _LIVE_ADAPTERS dict contains the active Weixin connection with valid session context
  • CLI agent: _LIVE_ADAPTERS dict is empty — each new process creates its own adapter instance without the valid session

When send_message is called, it runs in the CLI agent process, creates a brand-new WeixinAdapter instance, and attempts to send via the raw iLink API without the valid session context that the Gateway has already established.

Code Evidence

In tools/send_message_tool.py:

if platform == Platform.WEIXIN:
    return await _send_weixin(pconfig, chat_id, message, media_files=media_files)

In gateway/platforms/weixin.py, send_weixin_direct():

live_adapter = _LIVE_ADAPTERS.get(resolved_token)
if live_adapter is not None and send_session is not None and not send_session.closed:
    # Uses the live adapter's established session
    ...
else:
    # Falls back to creating a new adapter with a fresh connection
    async with aiohttp.ClientSession() as session:
        adapter = WeixinAdapter(...)
        # New connection, no valid session context

Since _LIVE_ADAPTERS is a module-level dict, each Python process has its own copy. The Gateway has the valid connection; the CLI agent doesn't.

Observed Behavior

  1. Gateway process shows active TCP connections to iLink servers
  2. CLI agent process has NO active connections to iLink
  3. Weixin messages sent via Gateway connection work (user confirmed receiving messages)
  4. Weixin messages sent via send_message tool consistently fail with -14 (session timeout)

Suggested Fix

send_weixin_direct() should route through the Gateway's IPC mechanism instead of creating independent connections. Other platforms (Telegram, Discord) may have the same issue.

See: gateway/platforms/weixin.py:send_weixin_direct() and tools/send_message_tool.py:_send_weixin()

extent analysis

TL;DR

Modify the send_weixin_direct() function to use the Gateway's IPC mechanism for sending Weixin messages instead of creating a new connection.

Guidance

  • Investigate the Gateway's IPC mechanism to understand how it can be used for sending Weixin messages.
  • Update the send_weixin_direct() function to route messages through the Gateway's IPC mechanism instead of creating independent connections.
  • Review other platforms (e.g., Telegram, Discord) to ensure they are not affected by the same issue.
  • Verify that the _LIVE_ADAPTERS dict is properly shared or synchronized between the Gateway and CLI agent processes.

Example

No code example is provided as the necessary changes depend on the specific implementation of the Gateway's IPC mechanism.

Notes

The fix may require significant changes to the send_weixin_direct() function and potentially other parts of the codebase. It is essential to thoroughly test the updated code to ensure that it works correctly for all platforms.

Recommendation

Apply workaround: Modify the send_weixin_direct() function to use the Gateway's IPC mechanism. This approach addresses the root cause of the issue and ensures that the valid session context is used for sending Weixin messages.

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