fix(gateway): log silent file-delivery drops (#39767)

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.
This commit is contained in:
Teknium 2026-06-05 04:50:04 -07:00 committed by GitHub
parent d41427504e
commit 947e21b3d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View file

@ -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()

View file

@ -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(