fix(gateway): pass explicit .ogg output_path for Telegram auto-TTS - #860
Open
hashbender wants to merge 1 commit into
Open
fix(gateway): pass explicit .ogg output_path for Telegram auto-TTS#860hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
hashbender
pushed a commit
that referenced
this pull request
Jul 13, 2026
…ousResearch#58327) Strict providers (DeepSeek) reject a payload where the same tool_call_id appears more than once with HTTP 400 'Duplicate value for tool_call_id'. The issue was filed as an 'orphaned tool message' compression bug, but the pasted error is a DUPLICATE tool_call_id — orphans are already handled on main; duplicates were not. Reproduced live on main: both shapes leaked through repair_message_sequence and sanitize_api_messages. Two chokepoints, two shapes: - repair_message_sequence: consume the id from known_tool_ids on first match so a SECOND tool result reusing it falls into the drop branch (duplicate tool-result shape). This is @Robinlovelace's kernel from NousResearch#55436 (applied manually — that PR was ~800 commits stale and bundled an unrelated duplicate-DB-write change for #860, which is dropped here). - sanitize_api_messages (final pre-API pass): add a dedup pass covering BOTH (a) duplicate tool_calls sharing an id WITHIN one assistant message (the message[6] shape) and (b) later tool result messages reusing an already-seen id. NousResearch#55436 covered neither of these at this chokepoint. Tests: duplicate-tool-result dedup at both functions, duplicate-assistant- tool_call-id collapse, and a negative control proving distinct ids are never dropped (no over-dedup). Credit: @Robinlovelace (NousResearch#55436) for the repair_message_sequence dedup kernel. Closes NousResearch#58327.
hashbender
pushed a commit
that referenced
this pull request
Jul 27, 2026
- codex app-server sibling path: surface a WARNING (was silent debug) when the projected-message flush fails — same bug class as the main fix, but codex output has already streamed so fail-closed and agent_persisted=False are both wrong here (#860/NousResearch#42039 duplicate-write hazard); loud durability gap logging instead. - map session_persistence_failed in _format_turn_completion_explanation so the user sees an actionable reason instead of 'The request failed: unknown error' + explainer test. - contributors/emails mapping for elco@thedaoist.gg (attribution CI).
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 a bug where the base platform adapter's auto-TTS path calls
text_to_speech_toolwithout an explicitoutput_path, causing Telegram voice replies to be sent as regular audio attachments (sendAudio) instead of native voice bubbles (sendVoice).The root cause:
text_to_speech_toolusesget_session_env("HERMES_SESSION_PLATFORM")to detect the platform and choose the output format. The session contextvar is set by_set_session_env()inside_handle_message_with_agent()and cleared on return. The auto-TTS code inbase.py's_process_message_backgroundruns after the agent returns, so the contextvar is empty — the tool defaults to.mp3regardless of platform.The fix: pass an explicit
output_pathwith the correct extension (.oggfor Telegram,.mp3otherwise) based onself.platform, which is always available on the adapter instance.Related Issue
Fixes NousResearch#57049
Type of Change
Changes Made
gateway/platforms/base.py: Build an explicitoutput_pathwith the correct extension based onself.platformbefore callingtext_to_speech_toolin the auto-TTS block. Addedimport tempfile.tests/gateway/test_base_topic_sessions.py: Added regression testtest_telegram_auto_tts_passes_explicit_ogg_output_pathverifying that the TTS tool receives an.oggoutput_path on Telegram.How to Test
python -m pytest tests/gateway/test_base_topic_sessions.py -q— all 11 tests should passself.platform == Platform.TELEGRAMand auto-TTS is enabled,text_to_speech_toolis called withoutput_pathending in.oggvoice.auto_tts: trueandtts.provider: edge, voice replies should render as native voice bubbles (tap-to-play) instead of audio file attachmentsChecklist
Code
fix(scope):,feat(scope):, etc.)python -m pytest tests/gateway/test_base_topic_sessions.py -qand all 11 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/Aself.platformattribute)Screenshots / Logs
N/A — regression test validates the fix programmatically.
Mirror-of: NousResearch#57071
NousResearch#57071