fix(gateway): bind session context for auto tts - #34779
Closed
Lbatson wants to merge 2 commits into
Closed
Conversation
Collaborator
Author
|
Closing this PR per maintainer request; the issue is already covered by other PRs/discussion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes Telegram gateway auto-TTS delivery so voice replies are sent with the correct Telegram session context and arrive as native voice bubbles instead of MP3/audio attachments.
The gateway auto-TTS path calls
text_to_speech_tool()from the platform send pipeline, outside the normal agent tool-call context. The TTS tool chooses Telegram Opus/OGG output based on gateway session context, but that context was not reliably bound for this out-of-band path. This PR temporarily rebinds the current gateway event context while calling TTS, then restores the previous context afterward.This keeps the fix scoped to the auto-TTS call, preserves any prior context, and covers more than just the platform string: platform, chat ID, session key, and message ID are all available to the TTS tool during the call.
Related Issue
No issue filed.
Related existing PRs found during duplicate check:
This PR is intentionally minimal: one gateway context-binding fix plus a regression test.
Type of Change
Changes Made
gateway/platforms/base.pytext_to_speech_tool()call.finallyso the binding cannot leak past the TTS send scope.tests/gateway/test_tts_media_routing.pyplatform: telegramchat_idsession_keymessage_idHow to Test
Test evidence from this branch:
Full-suite preflight:
The full-suite failures were outside this change area:
tests/hermes_cli/test_cmd_update.py::TestCmdUpdateBranchFallback::test_update_refreshes_repo_and_tui_node_dependenciestests/tools/test_browser_hardening.py::TestFindAgentBrowserCache::test_not_found_cached_raises_on_subsequenttests/tools/test_browser_homebrew_paths.py::TestFindAgentBrowser::test_raises_when_not_foundThe two browser failures timed out while attempting to install/download Chromium via
agent-browser; the update-command failure asserted unrelated web dashboard build helper behavior. None touchgateway/platforms/base.pyor TTS media routing.Live verification:
hermes-gateway.service..oggoutput present (audio_9bb55ddcaceb.ogg), with an MP3 intermediate only.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Live Telegram verification passed: the reply is delivered as a native voice message rather than an MP3/audio attachment.