Skip to content

The agent that grows with you

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

Fraser Humphries8f4122efd29d
diff --git a/tests/gateway/test_media_extraction.py b/tests/gateway/test_media_extraction.py
index 54202d791bf..65f64e6650b 100644
--- a/tests/gateway/test_media_extraction.py
+++ b/tests/gateway/test_media_extraction.py
@@ -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