Skip to content

fix(telegram): use native quote text for partial reply context - #22709

Closed
Ninso112 wants to merge 1 commit into
NousResearch:mainfrom
Ninso112:fix/telegram-native-quote
Closed

fix(telegram): use native quote text for partial reply context#22709
Ninso112 wants to merge 1 commit into
NousResearch:mainfrom
Ninso112:fix/telegram-native-quote

Conversation

@Ninso112

@Ninso112 Ninso112 commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug where Telegram's native partial quote feature was ignored, causing the agent to receive the entire replied-to message instead of just the user-selected quoted text
  • When message.quote (TextQuote) is available, the adapter now uses quote.text as reply_to_text, falling back to the full reply_to_message.text only when no native quote exists
  • Adds 3 tests covering: native quote usage, fallback to full text, and no-reply-context messages

Why

When a user replies using Telegram's native quote feature to select only part of a previous message, the adapter was ignoring message.quote and injecting the entire replied-to message as reply_to_text. This could materially change the user's intent — for example, if Hermes sent a multi-item briefing and the user quoted just one item with "mark this done", the agent would see the entire briefing and might act on the wrong item.

The fix uses python-telegram-bot's existing Message.quote / TextQuote API (documented since v22.7) to respect the user's selected quote text.

Closes #22619

When a user replies using Telegram's native quote feature to select only
part of a previous message, the adapter was ignoring message.quote and
injecting the entire replied-to message as reply_to_text. This could
materially change the user's intent by exposing unrelated text to the
agent.

Now checks for message.quote (TextQuote) first and uses quote.text when
available, falling back to the full reply_to_message.text only when no
native quote exists.

Fixes NousResearch#22619
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter duplicate This issue or pull request already exists labels May 9, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #22676 (merged). The same fix — honoring message.quote for partial-quote reply context — was already merged.

@teknium1

Copy link
Copy Markdown
Contributor

This looks implemented on current main by the already-merged duplicate PR #22676.

Evidence from this automated hermes-sweeper review:

Closing as already implemented on main. Thanks for the useful report and patch.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram native partial quotes are expanded to the full replied-to message

3 participants