fix(weixin): split poll/send sessions and reuse live adapter to prevent message loss - #10091
Closed
LLQWQ wants to merge 1 commit into
Closed
fix(weixin): split poll/send sessions and reuse live adapter to prevent message loss#10091LLQWQ wants to merge 1 commit into
LLQWQ wants to merge 1 commit into
Conversation
… cron & send_message - gateway/platforms/weixin.py: - Split aiohttp.ClientSession into _poll_session and _send_session - Add _LIVE_ADAPTERS registry so send_weixin_direct() reuses the connected gateway adapter instead of creating a competing session - Fixes silent message loss when gateway is running (iLink token contention) - cron/scheduler.py: - Support comma-separated deliver values (e.g. 'feishu,weixin') for multi-target delivery - Delay pconfig/enabled check until standalone fallback so live adapters work even when platform is not in gateway config - tools/send_message_tool.py: - Synthesize PlatformConfig from WEIXIN_* env vars when gateway config lacks a weixin entry - Fall back to WEIXIN_HOME_CHANNEL env var for home channel resolution - tests/gateway/test_weixin.py: - Update mocks to include _send_session
LLQWQ
force-pushed
the
fix/weixin-reuse-live-adapter
branch
from
April 16, 2026 07:11
f16e120 to
520c8d1
Compare
This was referenced Apr 17, 2026
teknium1
added a commit
that referenced
this pull request
Apr 17, 2026
…x Weixin test mocks Cron origin fallback extension (builds on #9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR #11317 using the architecturally-correct dict-based lookup from #9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on #10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but #10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
teknium1
added a commit
that referenced
this pull request
Apr 17, 2026
…x Weixin test mocks Cron origin fallback extension (builds on #9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR #11317 using the architecturally-correct dict-based lookup from #9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on #10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but #10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
Contributor
|
Merged as part of Batch-4 salvage: #11594 Full PR cherry-picked onto current
Had to resolve one conflict in Commit SHAs on main: 5ca52ba |
brucephaner
pushed a commit
to brucephaner/xiashou-agent
that referenced
this pull request
Apr 25, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but companion setter so the tests stay green with the session split in place. (cherry picked from commit f64241e)
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
prmartinow
pushed a commit
to prmartinow/hermes-agent
that referenced
this pull request
Aug 26, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
…x Weixin test mocks Cron origin fallback extension (builds on NousResearch#9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR NousResearch#11317 using the architecturally-correct dict-based lookup from NousResearch#9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on NousResearch#10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but NousResearch#10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
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.
Summary
This is a comprehensive fix for silent Weixin message loss when the gateway is running.
Root Cause
When the gateway is running, cron jobs and
send_messagetargeting Weixin would create a competing iLink session with the same bot token. The iLink backend sometimes returns HTTP 200, but messages are silently dropped or severely delayed because the long-poll session and the standalone session conflict.Changes
gateway/platforms/weixin.py
aiohttp.ClientSessioninto_poll_session(inbound long-poll) and_send_session(outbound sends)_LIVE_ADAPTERSregistry that maps bot tokens to the currently-connected gateway adaptersend_weixin_direct()now prefers reusing the live adapter's_send_sessionand only falls back to a fresh short-lived session when the gateway is not runningcron/scheduler.py
delivervalues (e.g."feishu,weixin") for multi-target deliverypconfig.enabledcheck until the standalone fallback path, so live adapters work even when the platform is not explicitly listed ingateway.json/config.yamltools/send_message_tool.py
PlatformConfigfromWEIXIN_*environment variables when the gateway config lacks a Weixin entryWEIXIN_HOME_CHANNELenv var for home channel resolutionsend_message(target="weixin:...")to work with pure.envconfigurationtests/gateway/test_weixin.py
_send_sessionTesting
tests/gateway/test_weixin.py,tests/cron/test_scheduler.py,tests/tools/test_send_message_tool.py)send_messageto Weixin via both live adapter and fallback pathsCloses #10089