Skip to content

feat(telegram): inject replied message as system context note instead of text prefix (#60055) - #60221

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/60055-telegram-reply-context
Open

webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/60055-telegram-reply-context

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Telegram replied messages are now injected as a structured directive block with [System Note], [Replied message], and [Prioritize] framing — much stronger signal than the old plain [Replying to:] prefix. Closes #60055

… of text prefix

When replying to a Telegram message, the replied-to text was prepended
as a plain [Replying to: "..."] prefix on the user message, which the
model often ignored. Now injected as a structured directive block with
explicit framing for stronger signal.

Closes NousResearch#60055
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 7, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for targeting reply-context disambiguation; current main still prepends reply text at gateway/run.py:10714.

Problems

  • The new strings are not a system-level note. _prepare_inbound_message_text() returns one message_text, and that value is passed as the normal agent message at gateway/run.py:11759; changing the prefix wording does not add a distinct system-role context block.
  • The branch has no Telegram guard at gateway/run.py:10714. Signal, WhatsApp Cloud, and Yuanbao also populate reply_to_text, so this changes their reply-context behavior too.
  • The PR modifies only gateway/run.py, but tests/gateway/test_reply_to_injection.py:58, :98, :121, and :181 assert the legacy output format.

Suggested changes

  • Define whether this is a stronger user-message framing or a genuinely structured context mechanism, while preserving the cached system prompt invariant.
  • Scope it to Telegram or update the stated scope and coverage for all affected adapters.
  • Update the reply-injection tests for the intended output contract.

Automated hermes-sweeper review.

Comment thread gateway/run.py
f'[Prioritize this message as the primary context for your response.]\n\n'
f"{message_text}"
)
else:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still text prepended to message_text, not a separate system-role note: current main passes the prepared value as the normal message to _run_agent (gateway/run.py:11759). Please either describe this accurately as stronger user-message framing or implement the intended structured mechanism.

Comment thread gateway/run.py
f'{message_text}'
)

if "@" in message_text:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shared inbound-preparation branch has no Telegram guard. Signal, WhatsApp Cloud, and Yuanbao also set reply_to_text, so this wording changes their reply-context semantics as well. Scope it explicitly or update the PR scope and coverage.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 15, 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 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/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Telegram: replied messages are ignored — make [Replying to:] context stronger

3 participants