From 947e21b3d69f34d33559c20ed86d596fd83f0782 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 5 Jun 2026 04:50:04 -0700 Subject: [PATCH] fix(gateway): log silent file-delivery drops (#39767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the agent's reply references a deliverable file path that does not exist on disk, extract_local_files dropped it from native delivery with no log line — the most common reason a promised file never arrives over a messaging platform. Add an INFO log at that drop point so the gap is visible in gateway.log instead of vanishing. Also convert the two print() calls in Telegram's send_document / send_video exception handlers to logger.warning(exc_info=True). print() writes to stdout, which 'hermes logs' never captures, so outbound upload failures (oversized files, Bot API rejections) were invisible. --- gateway/platforms/base.py | 11 +++++++++++ gateway/platforms/telegram.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index b8f74485151..76084b3cb68 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -3016,6 +3016,17 @@ class BasePlatformAdapter(ABC): expanded = os.path.expanduser(raw) if os.path.isfile(expanded): found.append((raw, expanded)) + else: + # The reply mentions a deliverable-looking path that does not + # exist on disk, so it is silently dropped from native delivery. + # This is the most common reason a promised file never arrives + # (the model said "here's your file" but never wrote it, or + # referenced the wrong path). Log it so the gap is visible in + # gateway.log rather than vanishing without a trace. + logger.info( + "Skipping bare file path in reply (no file on disk): %s", + _log_safe_path(raw), + ) # Deduplicate by expanded path, preserving discovery order seen: set = set() diff --git a/gateway/platforms/telegram.py b/gateway/platforms/telegram.py index fa55f2db004..d2b425b52b9 100644 --- a/gateway/platforms/telegram.py +++ b/gateway/platforms/telegram.py @@ -4073,7 +4073,7 @@ class TelegramAdapter(BasePlatformAdapter): ) return SendResult(success=True, message_id=str(msg.message_id)) except Exception as e: - print(f"[{self.name}] Failed to send document: {e}") + logger.warning("[%s] Failed to send document: %s", self.name, e, exc_info=True) return await super().send_document(chat_id, file_path, caption, file_name, reply_to, metadata=metadata) async def send_video( @@ -4120,7 +4120,7 @@ class TelegramAdapter(BasePlatformAdapter): ) return SendResult(success=True, message_id=str(msg.message_id)) except Exception as e: - print(f"[{self.name}] Failed to send video: {e}") + logger.warning("[%s] Failed to send video: %s", self.name, e, exc_info=True) return await super().send_video(chat_id, video_path, caption, reply_to, metadata=metadata) async def send_image(