Skip to content

fix(weixin): add prefer_platform_transcription config option - #81735

Open
answerallen wants to merge 1 commit into
NousResearch:mainfrom
answerallen:fix/weixin-prefer-platform-transcription
Open

fix(weixin): add prefer_platform_transcription config option#81735
answerallen wants to merge 1 commit into
NousResearch:mainfrom
answerallen:fix/weixin-prefer-platform-transcription

Conversation

@answerallen

Copy link
Copy Markdown

What does this PR do?

Adds a prefer_platform_transcription config option to the WeChat (Weixin) adapter that lets users choose between Tencent Cloud's STT and Hermes' own local STT pipeline for voice messages.

When true: trust Tencent's voice_item.text as the message body, skip downloading raw audio.
When false (default): always download raw audio and route through Hermes' local STT pipeline (unchanged from #27300).

Problem

After #27300 was merged (PR #73515), Hermes always ignores Tencent Cloud's voice_item.text and downloads raw .silk audio for local STT re-transcription. This fixed garbled transcriptions for non-Chinese users but broke Chinese-heavy users who:

  • Have stt.enabled: false (no local STT provider configured — no faster-whisper, no GROQ_API_KEY, etc.)
  • Were previously relying on Tencent Cloud's high-quality Chinese STT
  • After upgrading, voice messages become a placeholder ([The user sent a voice message: ...]) with no transcript at all

This is a common setup for Chinese users on low-resource servers where installing faster-whisper is impractical (300MB+ model, OOM risks on ≤2GB RAM).

Solution

Add prefer_platform_transcription to gateway.platforms.weixin.extra:

gateway:
  platforms:
    weixin:
      extra:
        prefer_platform_transcription: true

Changes

gateway/platforms/weixin.py:

  • _extract_text(): new prefer_platform_transcription keyword arg. When true, returns Tencent's voice_item.text as the message body (with [Voice transcription provided by Weixin] prefix from fix(weixin): preserve voice transcript origin #65022).
  • _download_voice(): when prefer_platform_transcription is true and Tencent text is available, returns None (skip audio download).
  • WeixinAdapter.__init__(): reads extra.prefer_platform_transcription (default: false).

tests/gateway/test_weixin.py:

  • New TestWeixinPreferPlatformTranscription class with 8 tests covering:
    • Text extraction with/without the flag
    • Audio download skip/download behavior
    • Config coercion

Behavior matrix

prefer_platform_transcription Has Tencent text Has raw audio Result
false (default) yes yes Download audio, ignore Tencent text (#27300 behavior)
false (default) yes no Use Tencent text (nothing else available)
false (default) no yes Download audio, local STT
true yes yes Use Tencent text, skip audio download
true no yes Download audio, local STT (fallback)
true no no Empty (nothing available)

Related Issue

Related to #27300, #65022. Does not revert #27300 — adds an opt-in escape hatch for users who want platform-side transcription.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

How to Test

  1. Set gateway.platforms.weixin.extra.prefer_platform_transcription: true
  2. Send a Chinese voice message via WeChat
  3. Confirm the agent receives [Voice transcription provided by Weixin]\n<transcript>
  4. Set it to false (or remove), send the same voice message
  5. Confirm audio is downloaded and local STT is used instead

Automated:

scripts/run_tests.sh tests/gateway/test_weixin.py -v

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched existing PRs and issues
  • My PR contains only related changes
  • Default behavior is unchanged (opt-in only)

When WeChat (Weixin) delivers a voice message, Tencent Cloud provides
voice_item.text as its own STT output. After NousResearch#27300, Hermes always
ignores this text and downloads the raw audio for local STT re-transcription.

This is correct for non-Chinese users (Tencent's STT garbles Russian,
Arabic, etc.) but breaks Chinese-heavy users who:

- Have stt.enabled=false (no local STT configured)
- Were previously relying on Tencent's high-quality Chinese transcription
- After upgrading, voice messages became unusable (placeholder with no
  transcript)

This PR adds prefer_platform_transcription (default: false) to
gateway.platforms.weixin.extra. When enabled:

- _extract_text() returns Tencent's voice_item.text as the message body
- _download_voice() skips downloading the .silk audio file

When disabled (default), behaviour is unchanged from NousResearch#27300.

Related: NousResearch#27300, NousResearch#65022
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery tool/tts Text-to-speech and transcription platform/wecom WeCom / WeChat Work adapter area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists 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 labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter 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 tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants