fix(telegram): accept html document uploads - #40584
Conversation
|
Adding HTML/HTM files to the text injection path is a natural extension, but there's an important difference from .md/.txt files: HTML documents can contain DOCTYPE declarations, |
327edd2 to
f7bd3fa
Compare
|
Good point — I agree raw HTML is noisier than I updated the branch to sanitize HTML before inline injection:
I also added a regression test covering a Updated test plan: |
|
Thanks for addressing the HTML-noise concern raised in the discussion. Problems
Suggested changes
Automated hermes-sweeper review. |
|
Closing as superseded in its current form. Current main already accepts and inlines .html/.htm uploads through the shared text-document path. The remaining sanitizer concern is cross-platform (Telegram/Discord/Slack), not a Telegram-specific patch against the obsolete adapter path. If pursued, it should be a fresh shared-injection change with cross-adapter coverage. Thanks for the review. |
Summary
.htmland.htmto the shared inbound document allowlist withtext/htmlMIME type..txt/.mduploads.script,style,noscript,head, comments, andDOCTYPEboilerplate while preserving visible body content.Why
Telegram currently rejects
.htmluploads before the agent can inspect them:This is inconsistent with Hermes' outbound/media delivery allowlist, which already treats
.html/.htmas deliverable document/web output extensions. For inbound Telegram uploads, the file should be cached and made visible to the agent instead of rejected at the adapter layer.Small HTML uploads are text-like enough to inline, but raw HTML often includes
DOCTYPE,head, CSS, JavaScript, and comments that waste context and can confuse the model. This patch strips those non-content blocks before injection and keeps the uploaded file cached as the original document.Test plan
python -m pytest tests/gateway/test_telegram_documents.py::TestDocumentDownloadBlock::test_supported_html_injects_content tests/gateway/test_telegram_documents.py::TestDocumentDownloadBlock::test_supported_html_injection_strips_non_content_blocks -o 'addopts=' -q2 passedpython -m pytest tests/gateway/test_telegram_documents.py tests/gateway/test_document_cache.py -o 'addopts=' -q72 passedpython -m py_compile gateway/platforms/base.py gateway/platforms/telegram.py