Skip to content

The agent that grows with you

docs(telegram): describe bounded update replay protection

Austin Pickett25f7d1098c63
diff --git a/website/docs/user-guide/messaging/telegram.md b/website/docs/user-guide/messaging/telegram.md
index 29ba3a41836..2b8cebbe6b6 100644
--- a/website/docs/user-guide/messaging/telegram.md
+++ b/website/docs/user-guide/messaging/telegram.md
@@ -114,6 +114,38 @@ Notes:
instance partially processed. Telegram's offset usually prevents this,
but time-sensitive commands sent during a long outage will run on boot.
+### Repeated inbound updates
+
+Hermes suppresses repeated Telegram `update_id` values before message batching,
+command/media handling, observed group-history writes and plugin observers.
+The receiving adapter and numeric bot ID scope this check; it does not deduplicate
+by text or `message_id`. A genuine edit with a new update ID can still be processed.
+
+This is bounded, **in-memory** protection, not an exactly-once guarantee:
+
+- The adapter remembers the most recent 4096 completed admissions, with no time
+ expiry. Active updates stay claimed until dispatch and its scheduled PTB handler
+ tasks finish, including nonblocking native plugins and registered error callbacks.
+- Reconnecting the same adapter retains that history. Eviction, adapter replacement
+ or a process restart can allow an old update through again. Nothing is written
+ to a replay ledger on disk.
+- Failed or cancelled preparation releases its claim if nothing has been handed
+ off. Once an update enters a batch/hold queue, gateway dispatch, an observer or
+ a native plugin, a later error does not reopen it. Native plugins own their own
+ partial effects, so entering their update or registered error callback is
+ conservatively treated as handoff. PTB's own exception logging is not a handoff.
+ Uncached static-sticker vision analysis is also a handoff: cancelling the await
+ cannot undo an auxiliary model request already submitted. Caught preparation
+ errors before any handoff remain retryable; an intentional refusal is terminal.
+- Releasing a claim only permits a later delivery; it does not request one from
+ Telegram. Polling acknowledgement is independent of agent completion. This check
+ does not retry failed replies or prevent a downstream component from independently
+ duplicating work.
+
+For a suspected late replay, compare both occurrences' bot/profile, chat/topic,
+`update_id`, update kind, `message_id` and actual receive time. An edit can reuse
+`message_id`, and the message's sent timestamp is not its receive time.
+
### Command menu priority and cap (Optional)
Hermes registers its command menu automatically when the Telegram gateway starts. The menu is built from the central slash-command registry plus eligible plugin/skill commands, then capped so Telegram accepts the payload reliably. The default cap is 60 commands — enough to keep all built-in commands plus common skill commands visible.