fix(telegram): preserve DM topic routing via reply fallback#22053
fix(telegram): preserve DM topic routing via reply fallback#22053leehack wants to merge 1 commit into
Conversation
|
Confirming this is the right fix shape from a code review of both this PR and #21941. The three-case framing in the body matches what the Bot API actually exposes:
The third case is the one #21941 mis-routed; sending Hermes-created lanes with Coverage matches what I flagged on #21941 as the gap (text streaming send was the only site that PR fixed; this PR covers all the other outgoing sites I listed). The propagation through Two small observations, neither blocking:
Approach is sound. Recommend merging this and closing #21941 as superseded. |
0a5c80a to
ed85e3d
Compare
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of #22053.
|
Thanks for this — your fix landed in #22410 (commit b323957 with your authorship preserved). Cherry-picked onto current main with one tiny follow-up commit on top: Your three-case framing (forum / true Bot API DM topic / Hermes-created DM topic lane) is the correct mental model — the propagation through the shared Closing as merged via #22410. Thanks again! |
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
…alvage (NousResearch#22409) Adds jhin.lee@unity3d.com → leehack so contributor_audit.py strict mode passes when the salvage of NousResearch#22053 (telegram DM topic reply fallback) lands on main.
The send path uses Hermes' reply-anchor fallback for DM topic lanes (message_thread_id + reply_to_message_id), but send_chat_action only accepts message_thread_id — Telegram's Bot API 10.0 rejects it for these lanes. Without this short-circuit, every typing tick (~every 2s during agent runs) makes a doomed API call that gets logged as a 'thread not found' debug warning. Skip the call entirely when the metadata indicates a DM topic reply-fallback lane; the user-visible behavior is unchanged (no typing indicator either way for these lanes), but the logs stay clean. Identified during salvage review of NousResearch#22053.
Summary
Fix Telegram replies for Hermes-created private DM topic lanes.
Telegram updates for these private lanes can arrive with
message_thread_idplus a reply anchor, but withoutdirect_messages_topic_id. Sending back with thatmessage_thread_idfails withMessage thread not found, and usingdirect_messages_topic_idtargets a different Bot API feature unless explicitly available. This PR preserves the inbound reply anchor in metadata and uses it as the routing fallback for Hermes-created Telegram DM topics.Fixes #22022.
Changes
telegram_dm_topic_reply_fallbackonly when a real reply anchor is available.telegram_reply_to_message_idthrough metadata-only send paths such as progress/status/streaming and follow-up turns.message_thread_id.direct_messages_topic_idmetadata.message_thread_id=1behavior.How to test
Reproduce on Telegram with a Hermes-created private DM topic lane:
message_thread_idand a reply anchor.Message thread not foundor falling back to the root chat.direct_messages_topic_idmetadata and verify it still routes via that field.Validation
venv/bin/python -m pytest tests/gateway/test_telegram_thread_fallback.py tests/gateway/test_run_progress_topics.py -q45 passedvenv/bin/python -m py_compile gateway/platforms/base.py gateway/platforms/telegram.py gateway/run.py tests/gateway/test_telegram_thread_fallback.pygit diff --checkNo blocking issues found.Related issues / PRs
Message thread not foundfrom spurious thread IDs.Message thread not foundin topic groups.Notes
This is related to Telegram topic routing issues where private-chat topic lanes are not represented as Bot API
direct_messages_topic_idon incoming updates. The fix intentionally separates three cases:message_thread_iddirect_messages_topic_id