Skip to content

fix(relay): deliver media from Git Bash paths and legacy connectors on Windows - #78333

Open
AutomatteAsia wants to merge 1 commit into
NousResearch:mainfrom
AutomatteAsia:fix/telegram-media-path-windows
Open

fix(relay): deliver media from Git Bash paths and legacy connectors on Windows#78333
AutomatteAsia wants to merge 1 commit into
NousResearch:mainfrom
AutomatteAsia:fix/telegram-media-path-windows

Conversation

@AutomatteAsia

Copy link
Copy Markdown

Problem

On native Windows, Hermes cannot deliver files (e.g. .pdf) to messaging platforms. The bundled Git Bash (MinGit) terminal reports paths in Unix format (/c/Users/...), and two code paths drop or reject the media:

  1. Git Bash paths fail the delivery gate. validate_media_delivery_path() checks Path.is_absolute(), which returns False for /c/Users/... (no drive letter). Every file the agent names is rejected as "unsafe" and silently falls back to a text notice. The same rejection hits _normalize_media_tag_path() (MEDIA: tags) and extract_local_files() (bare paths in the reply).

  2. Relay connectors never advertise send_media. send_media was added after the supported_ops discovery field (Phase 1 feat(relay): Phase 1 parity — supported_ops discovery, wire identity fields, /handoff aliasing, provision displayName #71300 came before Phase 2 feat(relay): Phase 2 media parity — send_media egress + inbound media localization #71363). A legacy connector (empty supported_ops) falls back to LEGACY_OPS = ("send", "edit", "typing", "follow_up"), which omits send_media - so the op-gated media lane is never attempted, even when the connector implements it.

Fix

  1. Normalize Git Bash paths in the three path consumers - validate_media_delivery_path, _normalize_media_tag_path, extract_local_files. On os.name == "nt", convert /c/Users/... ? C:\Users\.... The conversion is guarded on the drive letter actually existing (os.path.isdir("C:\\")), so genuine POSIX-style paths like /r/a.png are left untouched.

  2. Fail open for send_media on legacy connectors. Respect an explicit op declaration that excludes send_media (the caller falls back to text, unchanged), but for legacy connectors (empty supported_ops - which predate the discovery field and can therefore never advertise the op even when they implement it), attempt the lane and let a transport decline degrade to the same text fallback.

Verification

  • Reproduced on current main: Git Bash path rejected by validate_media_delivery_path; relay send_media gated out for empty supported_ops.
  • After fix: /c/Users/... validates, extracts via MEDIA: tag and bare-path detection, and resolves to the real file; native C:\... paths behave unchanged.
  • Test suites: tests/gateway/relay/test_relay_media.py (12/12), test_media_tag_formatting_variants.py, test_media_tag_cleanup.py, test_media_extraction.py all green. The 6 remaining failures in the media suite are pre-existing Windows-vs-POSIX path-format assertions that also fail on clean main without this change.

…n Windows

Two fixes for native-Windows media delivery:

1. Accept Git Bash style paths (/c/Users/... -> C:\Users\...) in media
   delivery. The Hermes terminal on Windows runs via the bundled Git Bash
   (MinGit), which reports paths in Unix format. Path.is_absolute()
   returns False for those (no drive letter), so validate_media_delivery_path
   rejected every file the agent named as 'unsafe'. Normalize in the three
   path consumers (validate_media_delivery_path, _normalize_media_tag_path,
   extract_local_files), guarded on the drive actually existing so POSIX-style
   paths (/r/a.png) are left untouched.

2. Fail open for send_media on legacy relay connectors. send_media was added
   after the supported_ops discovery field, so a legacy connector (empty
   supported_ops) can never advertise it even when it implements it, and the
   op-gated lane silently fell back to a text notice. Respect an explicit op
   declaration that excludes send_media, but attempt the op for legacy
   connectors and let a transport decline degrade to the same text fallback.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants