Skip to content

fix(wecom): accept aibot hex keys and strip group mentions - #11750

Open
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/wecom-image-key-format
Open

sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/wecom-image-key-format

Conversation

@sgaofen

@sgaofen sgaofen commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • accept 64-character hex aeskey values from the WeCom aibot websocket while preserving the existing base64 callback flow
  • strip a configured plain-text @BotName prefix from group messages before slash-command detection
  • expose bot_display_name via config/env wiring and document it in the CLI config example

Root Cause

WeCom aibot image payloads can deliver aeskey as a 64-character hex string, but _decrypt_file_bytes() only tried base64 decoding. Group chat messages also arrive with a literal @DisplayName prefix and no structured mention metadata, so commands like @Hermes /reset never reached the existing slash-command path.

Testing

  • python3 -m py_compile /Users/stephenyu/Documents/hermes-agent-wt-11447/gateway/platforms/wecom.py /Users/stephenyu/Documents/hermes-agent-wt-11447/gateway/config.py /Users/stephenyu/Documents/hermes-agent-wt-11447/tests/gateway/test_wecom.py
  • uv run --directory /Users/stephenyu/Documents/hermes-agent-wt-11447 --extra dev pytest -o addopts='' /Users/stephenyu/Documents/hermes-agent-wt-11447/tests/gateway/test_wecom.py -q

Platform Tested

  • macOS

Contribution Guide Notes

@sgaofen

sgaofen commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the failing test check appears to be an unrelated upstream failure, not a regression in this WeCom patch. Both this PR and #11752 are red on the same test: tests/hermes_cli/test_opencode_go_in_model_list.py::test_opencode_go_appears_when_api_key_set, with the opencode-go model order coming back as ['kimi-k2.5', 'glm-5.1', 'glm-5', ...] instead of the asserted order. The WeCom-specific targeted regression suite still passes locally (34 passed).

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for isolating the WeCom AES-key issue. The remaining hex-key defect is real on current main: plugins/platforms/wecom/adapter.py:1069-1073 only pads and base64-decodes aeskey values.

Problems

  • The group-command half is already implemented by 8b1ff55f5382052a5d98246659136e632af13697; current main strips the leading group @mention at plugins/platforms/wecom/adapter.py:526-532.
  • The adapter moved from gateway/platforms/wecom.py to plugins/platforms/wecom/adapter.py in 46f2cc2844c1448f9bc35166c46b97c30af53dd0. Porting the old fallback directly would also lose the unpadded-base64 handling added in 8f4c0bf0882c3c7258a65e3adade12d5b08068ea.

Suggested changes

  • Port the exact 64-hex-character branch before the existing base64-padding path in plugins/platforms/wecom/adapter.py.
  • Keep main's existing mention handling; the new display-name config is no longer needed for the reported @BotName /command case.
  • Preserve the hex regression test in tests/gateway/test_wecom.py and update website/docs/user-guide/messaging/wecom.md:208-210, which currently documents base64 only.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(wecom): aibot image decryption fails + group @mention not stripped

3 participants