Skip to content

fix(wecom): extract inbound video/voice media instead of dropping them as empty messages - #123

Open
TaoMasterCoder wants to merge 1 commit into
NousResearch:mainfrom
TaoMasterCoder:fix/wecom-inbound-video-voice
Open

TaoMasterCoder wants to merge 1 commit into
NousResearch:mainfrom
TaoMasterCoder:fix/wecom-inbound-video-voice

Conversation

@TaoMasterCoder

Copy link
Copy Markdown
Contributor

What

Port of hermes-agent core PR NousResearch/hermes-agent#142800, closed without merging when the WeCom platform tree was deleted from core. The fix never landed anywhere — with it removed, this plugin still drops every inbound video/voice message.

Scenario / bug

WeCom AI-bot callbacks for msgtype=video / voice carry a {\"video\": {...}} / {\"voice\": {...}} container. _extract_media had no branch for them, so media_urls stayed empty and _on_message skipped the payload as an "empty WeCom message" — users sending video or voice got no reply and no forensics. Quotes of video/voice and mixed items were equally ignored.

Fix (ported hunk-for-hunk onto current wecom/)

  • _extract_media: video/voice refs at top level, in mixed items, and in quote.
  • Inbound download cap uses the documented 100MB callback limit (INBOUND_MEDIA_MAX_BYTES) instead of the 20MB outbound file cap, so a 25MB phone video no longer trips the guard.
  • _detect_av_mime magic-byte sniff (mp4/amr/silk/ogg/wav/webm) when WeCom's CDN labels A/V as application/octet-stream, for both base64 and URL paths.
  • Voice callbacks carrying only the platform STT transcript short-circuit (transcript is already routed via _extract_text).
  • Forensic log on the empty-message drop path (keys/types only, never url sign tokens) + warning on failed downloads.
  • _derive_message_type: video/* -> MessageType.VIDEO (TEXT when captioned).

Tests

TestWeComInboundVideoVoice in wecom/tests/test_wecom.py (ported from the core PR): 6 new tests, red 6/6 without the fix, green with it; whole file 58 passed against current core. (test_wecom_image_link_fallback.py fails identically on untouched main locally — core-version drift, unrelated.)

…m as empty messages

Port of hermes-agent core PR #142800 (closed when the WeCom platform moved out
of core). msgtype=video / voice callbacks carried no extraction branch, so the
message hit the adapter's empty-message drop path and the media never reached
the agent. Now _extract_media refs video/voice (top level, mixed, quote), the
inbound cap is the documented 100MB callback limit, A/V container magic is
sniffed when the CDN labels bytes octet-stream, and voice STT transcripts
short-circuit cleanly. _derive_message_type maps video -> VIDEO.

Tests: TestWeComInboundVideoVoice in wecom/tests/test_wecom.py (6 new; all red
without the fix, green with it; whole file 58 passed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant