Skip to content

fix(gateway): add missing send_voice() override to WhatsApp adapter - #9522

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/whatsapp-send-voice
Closed

fix(gateway): add missing send_voice() override to WhatsApp adapter#9522
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/whatsapp-send-voice

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the missing send_voice() method to the WhatsApp platform adapter. WhatsApp was the only adapter without this override — voice/audio messages fell back to the base class implementation which sent them as plain text paths (e.g. 🔊 Audio: /path/to/file.mp3) instead of native media attachments.

Related Issue

Fixes #9236

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

Added send_voice() to gateway/platforms/whatsapp.py that routes through the existing _send_media_to_bridge() with media_type="audio", consistent with send_image, send_video, and send_document.

The WhatsApp bridge (bridge.js) already handles the "audio" media type — it reads the file and sends sock.sendMessage({ audio: buffer, mimetype: "audio/mpeg" }). No bridge-side changes needed.

How to Test

  1. Configure Hermes with a WhatsApp gateway
  2. Trigger a voice message (e.g., TTS tool output or voice reply)
  3. Before: User receives plain text like 🔊 Audio: /tmp/hermes_voice/tts_reply_abc123.mp3
  4. After: User receives a native audio attachment in WhatsApp

Run the test suite:

pytest tests/gateway/test_whatsapp_send_voice.py -v

Tests verify:

  • send_voice method exists and is not the base class fallback ✅
  • Method signature matches the base class interface ✅
  • Routes through _send_media_to_bridge with type "audio"
  • All media methods (image, video, document, voice) are overridden ✅

Full suite:

pytest tests/ -q --ignore=tests/integration --ignore=tests/e2e

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS (Darwin 25.4.0, Apple Silicon), Python 3.11

Documentation & Housekeeping

  • Updated relevant documentation — or N/A
  • Updated cli-config.yaml.example — or N/A
  • Updated CONTRIBUTING.md or AGENTS.md — or N/A
  • Considered cross-platform impact — or N/A
  • Updated tool descriptions/schemas — or N/A

WhatsApp was the only platform adapter without a send_voice()
override. Voice/audio messages fell back to the base class
implementation which sent them as plain text paths instead of
native media attachments.

The new method routes through the existing _send_media_to_bridge()
with media_type="audio", consistent with send_image, send_video,
and send_document.

Fixes NousResearch#9236
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution, @luyao618!

Closing this as a duplicate of #6305 (by @duan78), which targets the same fix/feature. We're consolidating on that PR for review.

If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen.

@teknium1 teknium1 closed this Apr 21, 2026
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.

WhatsApp adapter missing send_voice() override — voice messages sent as text path

2 participants