Skip to content

Telegram: delivery-only notification sink for notifications.telegram_chat_id groups - #417

Open
serxa wants to merge 2 commits into
mainfrom
serxa/telegram-notification-sink
Open

Telegram: delivery-only notification sink for notifications.telegram_chat_id groups#417
serxa wants to merge 2 commits into
mainfrom
serxa/telegram-notification-sink

Conversation

@serxa

@serxa serxa commented Aug 31, 2026

Copy link
Copy Markdown
Member

What

Add an opt-in setting notifications.delivery_only_sink (default false). When enabled and notifications.telegram_chat_id points at a non-private group/supergroup, that chat becomes a one-way notification channel: notifications are delivered there, but inbound messages no longer start an agent turn.

Why

A user may want a dedicated Telegram group that only receives notifications (the notify tool, async questions/approvals, and the out-of-band tg-notify.sh helper), keeping the DM uncluttered. Without a guard, any message the bot receives in that group would spin up an agent session and reply.

The behaviour is gated behind an explicit flag so it is fully backward compatible: existing installs are unaffected unless they opt in — including an install that points telegram_chat_id at a group it also uses to talk to the bot (that group keeps responding unless delivery_only_sink is set).

Behavior (when delivery_only_sink: true)

  • Inbound messages in the configured non-private sink chat are ignored (logged, no turn).
  • A DM sink stays fully interactive — the guard requires a non-private chat, so pointing telegram_chat_id at the owner's own chat is unaffected.
  • Inline-button callbacks are handled separately, so questions/approvals delivered to the sink remain answerable.

Changes

  • nerve/config.py: add NotificationsConfig.delivery_only_sink (bool, default false) + from_dict parsing.
  • nerve/channels/telegram.py: add _is_delivery_only_sink() (gated on the flag), consulted at the top of _handle_message.
  • tests/test_telegram_notification_sink.py: unit tests for the predicate, including the flag-off backward-compat case.

…only sink

When notifications.telegram_chat_id points at a group/supergroup, pushes (the notify tool, async questions/approvals, tg-notify.sh) are delivered there, but inbound messages in that chat must not start an agent turn — it is a one-way notification channel. A DM sink stays interactive (the guard requires a non-private chat), and inline-button callbacks are handled separately so questions/approvals delivered there remain answerable. Adds _is_delivery_only_sink() + unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serxa
serxa marked this pull request as ready for review August 31, 2026 13:12
…very_only_sink flag

Make the delivery-only behaviour opt-in (default false) so it never changes behaviour for an existing install — including one that points notifications.telegram_chat_id at a group it also uses to talk to the bot (a group sink still responds unless the flag is enabled). Only when delivery_only_sink is true AND the sink is a non-private chat are inbound messages ignored. Adds the config field + from_dict parsing, gates _is_delivery_only_sink, and covers the flag-off case in tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant