Summary
gateway/platforms/base.py has two independent file-extension whitelists used for media routing that have drifted out of sync:
extract_media() parses explicit MEDIA:<path> directives produced by the model.
extract_local_files() finds bare local paths in response text.
extract_local_files's _LOCAL_MEDIA_EXTS accepts .html, .htm, .md, .svg, .bmp, .tiff, .json, .xml, .yaml, .yml, .tsv, .ods, .odp, .odt, .rtf, .key, .tar, .gz, .tgz, .bz2, .xz — but the regex inside extract_media does not.
When the model emits MEDIA:/abs/path/file.html (or any other missing extension), the extract_media regex doesn't match, the file is never attached, and the parent send_message tool still reports success: true because the text portion ships fine. Silent data loss, no log line at any level.
The (?<![/:\w.]) anti-URL guard inside extract_local_files also disqualifies the same path (the : after MEDIA defeats it), so the path falls between both detectors.
Reproduction
Telegram, gateway running:
- Put any file with one of the missing extensions on a media-allowed root, e.g.
/root/.hermes/media_cache/foo.html.
- Have the agent return a reply containing literally
MEDIA:/root/.hermes/media_cache/foo.html.
- Observe: text arrives, file does not.
send_message tool result is success: true.
Direct POST https://api.telegram.org/bot$TOKEN/sendDocument against the same file works first try — confirming the bug is in extraction, not transport.
Affected platforms
All platforms that use BasePlatformAdapter.extract_media — i.e. every messaging platform in gateway/platforms/. The bug only surfaces for extensions in the gap between the two lists, but those gaps cover common artifact types (HTML reports, Markdown notes, JSON exports, SVG charts, archives, etc.).
Root cause
gateway/platforms/base.py, around line 2270:
media_pattern = re.compile(
r'''[`"']?MEDIA:\s*(?P<path>`[^`\n]+`|"[^"\n]+"|'[^'\n]+'|(?:~/|/)\S+(?:[^\S\n]+\S+)*?\.(?:png|jpe?g|gif|webp|mp4|mov|avi|mkv|webm|ogg|opus|mp3|wav|m4a|flac|epub|pdf|zip|rar|7z|docx?|xlsx?|pptx?|txt|csv|apk|ipa)(?=[\s`"',;:)\]}]|$))[`"']?'''
)
vs.
_LOCAL_MEDIA_EXTS = (
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.tiff', '.svg',
'.mp4', '.mov', '.avi', '.mkv', '.webm',
'.mp3', '.wav', '.ogg', '.m4a', '.flac',
'.pdf', '.docx', '.doc', '.odt', '.rtf', '.txt', '.md',
'.xlsx', '.xls', '.ods', '.csv', '.tsv', '.json', '.xml', '.yaml', '.yml',
'.pptx', '.ppt', '.odp', '.key',
'.zip', '.tar', '.gz', '.tgz', '.bz2', '.xz', '.7z', '.rar',
'.html', '.htm',
)
The two lists need to stay in sync, but the structure (one is a regex alternation, one is a tuple) makes it easy to forget.
Expected behavior
Any extension accepted by extract_local_files should also be accepted by extract_media. A model emitting MEDIA:/path/to/report.html should result in the file being attached as a document (the same routing the bare-path detection would do).
Suggested fix
Extend the extract_media regex extension list to be a superset of _LOCAL_MEDIA_EXTS, and add a binding comment so future drift gets caught in review.
I have a PR ready: #<PR_NUMBER_PLACEHOLDER> (43-case parametrized regression test + the original user-reported repro path).
Environment
- Hermes Agent:
git rev origin/main ≈ f3fb7899d (May 2026)
- OS: Linux (Ubuntu, kernel 6.8.0-111-generic)
- Python 3.11, gateway running under user systemd unit
- Transport: Telegram bot
Summary
gateway/platforms/base.pyhas two independent file-extension whitelists used for media routing that have drifted out of sync:extract_media()parses explicitMEDIA:<path>directives produced by the model.extract_local_files()finds bare local paths in response text.extract_local_files's_LOCAL_MEDIA_EXTSaccepts.html,.htm,.md,.svg,.bmp,.tiff,.json,.xml,.yaml,.yml,.tsv,.ods,.odp,.odt,.rtf,.key,.tar,.gz,.tgz,.bz2,.xz— but the regex insideextract_mediadoes not.When the model emits
MEDIA:/abs/path/file.html(or any other missing extension), theextract_mediaregex doesn't match, the file is never attached, and the parentsend_messagetool still reportssuccess: truebecause the text portion ships fine. Silent data loss, no log line at any level.The
(?<![/:\w.])anti-URL guard insideextract_local_filesalso disqualifies the same path (the:afterMEDIAdefeats it), so the path falls between both detectors.Reproduction
Telegram, gateway running:
/root/.hermes/media_cache/foo.html.MEDIA:/root/.hermes/media_cache/foo.html.send_messagetool result issuccess: true.Direct
POST https://api.telegram.org/bot$TOKEN/sendDocumentagainst the same file works first try — confirming the bug is in extraction, not transport.Affected platforms
All platforms that use
BasePlatformAdapter.extract_media— i.e. every messaging platform ingateway/platforms/. The bug only surfaces for extensions in the gap between the two lists, but those gaps cover common artifact types (HTML reports, Markdown notes, JSON exports, SVG charts, archives, etc.).Root cause
gateway/platforms/base.py, around line 2270:vs.
The two lists need to stay in sync, but the structure (one is a regex alternation, one is a tuple) makes it easy to forget.
Expected behavior
Any extension accepted by
extract_local_filesshould also be accepted byextract_media. A model emittingMEDIA:/path/to/report.htmlshould result in the file being attached as a document (the same routing the bare-path detection would do).Suggested fix
Extend the
extract_mediaregex extension list to be a superset of_LOCAL_MEDIA_EXTS, and add a binding comment so future drift gets caught in review.I have a PR ready: #<PR_NUMBER_PLACEHOLDER> (43-case parametrized regression test + the original user-reported repro path).
Environment
git rev origin/main≈f3fb7899d(May 2026)