Skip to content

fix(gateway): require voice input for global auto-TTS fallback (#100431) - #100454

Open
twotnguyen wants to merge 1 commit into
NousResearch:mainfrom
twotnguyen:fix/gateway-auto-tts-voice-only-input
Open

twotnguyen wants to merge 1 commit into
NousResearch:mainfrom
twotnguyen:fix/gateway-auto-tts-voice-only-input

Conversation

@twotnguyen

Copy link
Copy Markdown
Contributor

What does this PR do?

When voice.auto_tts: true is configured globally in config.yaml, the messaging gateway was incorrectly sending TTS voice replies for normal typed MessageType.TEXT messages in chats that have no explicit per-chat /voice mode.

The contract of global auto-TTS is voice-to-voice (voice input -> text + voice reply; text input -> text reply only), while /voice tts (voice_mode == "all") remains the explicit mode that speaks replies to all messages.

This PR fixes the fallback condition in GatewayRunner._should_send_voice_reply() by requiring is_voice_input when relying on the global adapter_auto_tts fallback for chats with default voice mode (voice_mode is None).

Related Issue

Fixes #100431

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)

Changes Made

  • gateway/run.py: In _should_send_voice_reply(), add and is_voice_input to the voice_mode is None and adapter_auto_tts fallback check so typed text messages do not trigger unsolicited TTS voice replies.
  • tests/gateway/test_auto_voice_reply_format.py: Added regression test test_should_send_voice_reply_global_auto_tts_ignores_text_input asserting that text messages with global auto-TTS and default voice mode return False.

How to Test

  1. Run the regression test:
    python -m pytest tests/gateway/test_auto_voice_reply_format.py -k test_should_send_voice_reply_global_auto_tts_ignores_text_input
  2. Run the voice reply suite:
    python -m pytest tests/gateway/test_auto_voice_reply_format.py

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/gateway/test_auto_voice_reply_format.py and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11 / Python 3.11.15

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

@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/telegram Telegram bot 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 labels Sep 1, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Correctness bug fix for global auto-TTS voice replies

The change in gateway/run.py:24090 adds and is_voice_input to the global voice.auto_tts fallback branch. Previously, a text message arriving in a chat without an explicit voice mode would trigger a voice reply whenever the adapter-level auto_tts flag was enabled — which contradicts the documented "fallback" semantics (the adapter flag should only apply when the chat has no explicit mode, and voice replies are only meaningful for voice input). This fix scopes the fallback to voice input, aligning it with the chat-level branches which already gate on is_voice_input.

The regression test in tests/gateway/test_auto_voice_reply_format.py:25-30 directly covers the bug: it sets _should_auto_tts_for_chat = True with a TEXT message type and asserts _should_send_voice_reply(...) is False. The test reuses the existing _make_runner/_make_adapter helpers and MagicMock, so it follows the established test conventions.

Non-blocking: the test only asserts the text-input case; a symmetric positive assertion (voice input + global auto_tts still returns True) would guard against over-correction, but the existing test_should_send_voice_reply_voice_only_still_requires_voice_input already covers voice-input passing behavior.

Verdict: LGTM

@kvnloo

kvnloo commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Exact-head KEEP on #100454 head 45bafa3.

KEEP requiring voice input for the global auto-TTS fallback so voice.auto_tts: true no longer speaks replies to ordinary typed TEXT in chats without explicit /voice mode (#100431). KEEP /voice tts (voice_mode == "all") as the explicit speak-everything path. KEEP tests/gateway/test_auto_voice_reply_format.py.

CHECK: per-chat voice mode overrides still win. CHECK: Telegram path covered. Author twotnguyen not kvnloo. No competing PR.

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/telegram Telegram bot adapter 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.

[Bug]: Global voice.auto_tts speaks replies to typed text in gateway chats

4 participants