fix: use rich Telegram messages for standalone sends - #46952
Conversation
|
Duplicate of #46118 — both add a Telegram |
teknium1
left a comment
There was a problem hiding this comment.
Thanks—the current-main gap is real: standalone Telegram sends still format content and call legacy bot.send_message (tools/send_message_tool.py:1136-1144, 1242-1246), while the gateway has a richer delivery path.
Problems
tools/send_message_tool.py:806defaults rich delivery on and evaluates raw values withbool(). That conflicts with the documented/default opt-in athermes_cli/config.py:2505; notably,bool("false")is true while the gateway treats that value as an opt-out (plugins/platforms/telegram/adapter.py:1272-1283).tools/send_message_tool.py:1125bypasses the gateway's rich eligibility and client-safety guards (plugins/platforms/telegram/adapter.py:1452-1461), and:1128omits its newline normalization (:1506-1521).tools/send_message_tool.py:1149references the pre-plugingateway.platforms.telegrammodule, absent from current production paths. The fallback would consequently skip legacy chunking after a rich rejection.
Suggested changes
- Salvage this against the current sender, preserving the later UTF-16 chunking and media-caption work (b7c4369, 709da84).
- Share the gateway's opt-in coercion, eligibility, safe payload construction, and fallback behavior; add standalone regression coverage for these paths.
Automated hermes-sweeper review.
|
|
||
| # Platform message length limits (from adapter class attributes for | ||
| # built-in platforms; from PlatformEntry.max_message_length for plugins). | ||
| telegram_rich_enabled = bool( |
There was a problem hiding this comment.
Rich messages are opt-in on current main (hermes_cli/config.py:2505), but this defaults a missing value to True; additionally bool("false") is true. Please use the gateway's false-by-default string-aware coercion and add standalone opt-out regressions.
| @@ -1047,48 +1124,80 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No | |||
| warnings = [] | |||
|
|
|||
There was a problem hiding this comment.
This enables rich sends for every plain message, bypassing the gateway's construct eligibility and safety exclusions for details-plus-math and CJK-rich content (plugins/platforms/telegram/adapter.py:1452-1461). The standalone path needs to share that policy before attempting the raw endpoint.
| return _error(f"Telegram rich send failed: {rich_error}") | ||
|
|
||
| if last_msg is None: | ||
| try: |
There was a problem hiding this comment.
Current main migrated the Telegram adapter to plugins.platforms.telegram.adapter; gateway.platforms.telegram is not a tracked production module. This import will fail during rich fallback, leaving the whole formatted payload unchunked. Use the plugin path and preserve current post-format UTF-16 chunking.
Summary
sendRichMessagewhen availableTests
python -m pytest tests/tools/test_send_message_tool.py tests/hermes_cli/test_send_cmd.py tests/gateway/test_telegram_rich_messages.py -q