From 7a83f44c4a0ea452baae5a09e76bfff838dc3b4d Mon Sep 17 00:00:00 2001 From: webtecnica Date: Tue, 28 Jul 2026 23:16:25 -0300 Subject: [PATCH] fix(gateway): preserve explicit send-image requests from session-wide MEDIA dedup Closes #73771 The session-wide MEDIA dedup in (base.py) filtered ALL media paths against prior-turn history, including explicit MEDIA: tags the model deliberately included in its response text. When a user asked the agent to resend an image, the dedup silently swallowed it because that path already existed in the session transcript. The dedup is already handled correctly by the auto-append path in (run.py), which scopes its scan to the current turn and filters against via . The base.py filter was redundant for auto-appended tags and harmful for explicit ones. Fix: remove the dedup filter on in base.py while preserving the variable for the dedup (bare file paths, which lack run.py protection). --- gateway/platforms/base.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index 98588648db0..516545469f0 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -5859,17 +5859,15 @@ class BasePlatformAdapter(ABC): media_files, response = self.extract_media(response) media_files = self.filter_media_delivery_paths(media_files) - # Deduplicate against media already delivered in prior turns. - # The model may echo a previous MEDIA: tag or bare file path in - # a later response; without this guard the same file is sent - # repeatedly. + # Do NOT deduplicate MEDIA tags against prior turns here. + # The auto-append path in GatewayRunner._run_agent_inner already + # deduplicates auto-appended tags via _collect_auto_append_media_tags + # with history_media_paths, so this filter would only catch explicit + # MEDIA tags the model deliberately included in its response — which + # must be preserved (user asked to resend an image, the model echoed + # a path intentionally, etc.). Bare-file-path dedup still applies + # to local_files below via the same _history_media_paths set. _history_media_paths = self._history_media_paths_for_session(session_key) - if _history_media_paths: - media_files = [ - (path, is_voice) - for path, is_voice in media_files - if path not in _history_media_paths - ] # Extract image URLs and send them as native platform attachments images, text_content = self.extract_images(response)