test(gateway): cover current-turn TTS media dedup

This commit is contained in:
Fraser Humphries 2026-07-30 00:48:48 +12:00 committed by Teknium
parent 4dc9fb8008
commit 8f4122efd2

View file

@ -199,6 +199,45 @@ caption
)
assert paths == {old_path}
@pytest.mark.parametrize(
"current_path",
["/tmp/tts/current.ogg", "/tmp/tts/already-delivered.ogg"],
)
def test_non_streaming_dedup_scopes_tts_paths_to_prior_turns(
self, current_path
):
from gateway.platforms.base import BasePlatformAdapter
old_path = "/tmp/tts/already-delivered.ogg"
transcript = [
{"role": "user", "content": "say the old message"},
{"role": "assistant", "content": f"MEDIA:{old_path}"},
{"role": "user", "content": "say the current message"},
{
"role": "assistant",
"tool_calls": [
{"id": "tts", "function": {"name": "text_to_speech"}}
],
},
{
"role": "tool",
"tool_call_id": "tts",
"content": f"[[audio_as_voice]]\\nMEDIA:{current_path}",
},
{
"role": "assistant",
"content": f"[[audio_as_voice]]\\nMEDIA:{current_path}",
},
]
adapter = MagicMock()
adapter._session_store.peek_session_id.return_value = "session-id"
adapter._session_store.load_transcript.return_value = transcript
paths = BasePlatformAdapter._history_media_paths_for_session(
adapter, "session-key"
)
assert paths == {old_path}
def test_image_generate_not_reemitted_after_compression(self):
"""End-to-end of the #46627 fix: collect history paths, then the
compression-fallback rescan (history_offset stale) must dedup the