The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): exclude current-turn media from dedup
Fraser Humphries4dc9fb8008e6
diff --git a/tests/gateway/test_media_extraction.py b/tests/gateway/test_media_extraction.pyindex e0542956b2c..54202d791bf 100644--- a/tests/gateway/test_media_extraction.py+++ b/tests/gateway/test_media_extraction.py@@ -11,8 +11,10 @@ make_image tool several turns earlier must not leak onto a latertext-only reply, even when the path-based dedup set fails to capture it."""-import pytestimport re+from unittest.mock import MagicMock++import pytestdef extract_media_tags_fixed(result_messages, history_len):@@ -168,6 +170,35 @@ captionassert "/tmp/gen/cat.png" in paths # JSON-payload path (the bug)assert "/tmp/voice/note.ogg" in paths # MEDIA: text path (already worked)+ def test_non_streaming_dedup_excludes_current_turn_tool_output(self):+ from gateway.platforms.base import BasePlatformAdapter++ old_path = "/tmp/gen/old.png"+ current_path = "/tmp/gen/current.png"+ transcript = [+ {"role": "user", "content": "make the old image"},+ {"role": "assistant", "content": f"MEDIA:{old_path}"},+ {"role": "user", "content": "make a new image"},+ {+ "role": "assistant",+ "tool_calls": [{"id": "current", "function": {"name": "image_generate"}}],+ },+ {+ "role": "tool",+ "tool_call_id": "current",+ "content": f'{{"success": true, "image": "{current_path}"}}',+ },+ {"role": "assistant", "content": f"MEDIA:{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 thecompression-fallback rescan (history_offset stale) must dedup the