Skip to content

fix: treat [object Object] sentinel as absent in Telegram reply_to_text - #68428

Open
Jake-P-Shalmi wants to merge 1 commit into
NousResearch:mainfrom
Jake-P-Shalmi:fix/telegram-object-object-reply-text
Open

fix: treat [object Object] sentinel as absent in Telegram reply_to_text#68428
Jake-P-Shalmi wants to merge 1 commit into
NousResearch:mainfrom
Jake-P-Shalmi:fix/telegram-object-object-reply-text

Conversation

@Jake-P-Shalmi

Copy link
Copy Markdown

Summary

When a user replies to a rich message (sendRichMessage, Bot API 10.1), Telegram echoes the literal string [object Object] as reply_to_message.text instead of returning empty/None. The adapter accepted this as valid reply text (it's a truthy string), skipping the _extract_rich_reply_text and rich_sent_store.lookup fallbacks that would have recovered the real content.

This caused the agent to see [object Object] as the reply-to context instead of the actual message body — e.g. replying to a cron-delivered morning briefing produced:

[Replying to: "[object Object]"]
What is this?

Fix

Add a guard after the .text / .caption extraction that detects the [object Object] sentinel and sets reply_to_text = None. This lets the existing fallback chain fire as intended:

  1. _extract_rich_reply_text() — parses Telegram's native rich-message echo
  2. rich_sent_store.lookup() — recovers from the local send-time index

Test Plan

  • New test test_object_object_sentinel_treated_as_absent verifies the sentinel is not passed through
  • Existing reply-quote tests still pass (no regression)
tests/gateway/test_telegram_reply_quote.py::test_native_partial_quote_used_as_reply_to_text PASSED
tests/gateway/test_telegram_reply_quote.py::test_full_reply_text_used_when_no_native_quote PASSED
tests/gateway/test_telegram_reply_quote.py::test_caption_fallback_when_no_quote_and_no_text PASSED
tests/gateway/test_telegram_reply_quote.py::test_empty_quote_text_falls_back_to_full_reply PASSED
tests/gateway/test_telegram_reply_quote.py::test_object_object_sentinel_treated_as_absent PASSED
5 passed in 0.35s

When a user replies to a rich message (sendRichMessage, Bot API 10.1),
Telegram echoes the literal string '[object Object]' as
reply_to_message.text instead of returning empty/None. The adapter
accepted this as valid reply text (it's a truthy string), skipping the
rich-reply and sent-store fallbacks that would have recovered the real
content. This caused the agent to see '[object Object]' as the
reply-to context instead of the actual message body.

Add a guard that detects the sentinel and sets reply_to_text to None,
so the existing fallback chain (_extract_rich_reply_text →
rich_sent_store.lookup) fires as intended.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter labels Jul 21, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Telegram fallback fix. Current main still assigns reply_to_message.text at plugins/platforms/telegram/adapter.py:9640-9644 and only runs native-rich and sent-store recovery under if not reply_to_text at :9645-9655; therefore a truthy [object Object] sentinel bypasses both recovery paths. The proposed normalization to None makes the existing fallback chain run without changing normal reply text handling. Existing rich-reply coverage already verifies the absent-text recovery behavior in tests/gateway/test_telegram_rich_messages.py:1062-1088.

No blocking issues identified. This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 30, 2026
@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Fourteen PRs address or reference the Telegram reply-context complex: #1596/#1662 establish out-of-session reply context, while #2694/#22632/#22633/#22676/#22709/#23091/#70631 handle native partial quotes and agent-visible injection. The remaining PRs cover adjacent reply-context gaps: observed audio (#43200), topic quote metadata (#47487), forwarded and long reply context (#54262), reply authorship (#56203), and rich-message sentinel recovery (#68428).

Related pull requests

Duplicates

#1596 and #1662 share the #1594 reply-context core, with #1662 the focused merged extraction; #22632, #22633, #22676, #22709, and #23091 implement substantially the same #22619 partial-quote fix, with #22676 the merged salvage, while #2694 overlaps that core and additionally removes injection suppression; #70631 duplicates the already agent-visible partial-quote path on main.

Suggested consolidation

Keep #68428 open with its focused salvage path: normalize [object Object] before the existing rich-reply fallbacks, consistent with the maintainer-bot keep-open verdict. Retain #43200, #47487, #54262, and #56203 only for the contributor-reviewed salvage actions stated above; the closed duplicate chains should remain closed, and merged #1662/#22676 remain the reference implementations for their respective issues.

Cross-PR triage: Reviewed 14 pull requests and 2 issues in this complex. Each diff was read against this issue; Assessment working set: 160 kB of PR diffs, 31 kB of issue/PR text, 17 kB of discussion (16 comments), 14 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants