Skip to content

feat(telegram): option to ignore messages that @mention humans (#64388) - #64456

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/64388-telegram-mention
Open

feat(telegram): option to ignore messages that @mention humans (#64388)#64456
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/64388-telegram-mention

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Fixes #64388. Adds ignore_human_mentions config option (and TELEGRAM_IGNORE_HUMAN_MENTIONS env var) so bot ignores group messages that @mention human users.

@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have labels Jul 14, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Feature adding option to ignore messages that @mention humans in Telegram. Substantial feature (243 additions, 428 deletions). No security concerns. Note: contains keywords that matched the security scan (telegram, ignore, allowlist) but these are standard feature-related terms, not credentials.


Reviewed by Hermes Agent

@webtecnica
webtecnica force-pushed the fix/64388-telegram-mention branch from 81d97f5 to f9c94ed Compare July 15, 2026 15:14
@webtecnica

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/main.

The PR's original commit also touched polling resilience code that has since been rewritten on main. The rebase preserves the core feature (ignore_human_mentions) while keeping upstream/main's polling code intact. Author attribution preserved.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for rebasing this focused Telegram feature. The issue premise still holds on current main: plugins/platforms/telegram/adapter.py:7762-7765 accepts free-response and require_mention: false group messages without a human-mention gate.

Problems

  • The new filter at plugins/platforms/telegram/adapter.py:7883 runs only after the accepting returns at :7865-7868. It therefore cannot suppress the free-response path described in #64388.
  • _message_only_mentions_humans() documents that an own-bot mention makes it return false, but it preserves found_human_mention=True after skipping an own-bot entity (:7111-7122, :7141). Mixed human-plus-bot mentions would not preserve the direct-address exception once the gate is moved.
  • plugins/platforms/telegram/plugin.yaml:36-39 adds a user-facing non-secret environment setting. AGENTS.md:102-107 requires behavioral configuration through config.yaml instead.
  • The two-file diff adds no regression tests; tests/gateway/test_telegram_group_gating.py:153-156 is the existing free-response contract that needs coverage for this option.

Suggested changes

  • Gate human-only mentions before free-response / disabled-require-mention admission, after preserving replies and direct bot addressing (including /command@botname).
  • Keep this as telegram.ignore_human_mentions config only, remove the new environment variable, document it, and add gating tests for the direct-address and caption/entity cases.

Automated hermes-sweeper review.

# The message already passed all other gates (free_response, require_mention
# disabled, reply-to-bot, @bot, wake-word patterns) so this is the final
# filter before falling through to the default-reject path.
if self._telegram_ignore_human_mentions() and self._message_only_mentions_humans(message):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch is unreachable for the feature’s target mode: free_response_chats and require_mention: false both return True at lines 7865-7868 before reaching here. Move the suppression decision ahead of those admissions, while retaining the reply/direct-bot exceptions.

if isinstance(configured, str):
return configured.lower() in {"true", "1", "yes", "on"}
return bool(configured)
return os.getenv("TELEGRAM_IGNORE_HUMAN_MENTIONS", "false").lower() in {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep this behavioral setting config.yaml-only and remove the new optional non-secret environment fallback. The repository policy in AGENTS.md:102-107 reserves .env for credentials/secrets.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 16, 2026
@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Nineteen PRs address or reference this Telegram group-routing complex: #64456 is the direct implementation for #64388, while the others establish or refine mention gating, command routing, entity parsing, configuration, and documentation. The #64456 diff adds optional human-mention detection, but the guard follows the free-response and require_mention: false acceptance paths and therefore does not yet suppress the reported messages.

Related pull requests

Duplicates

#1977, #2000, #2508, #3539, and #4019 overlap on Telegram require_mention gating and were superseded by #3870; #6036 was salvaged by #13438; #12637 and #12826 were superseded by #12848; #18672 was salvaged by #20416; #19317 was salvaged by #19429; #20464 duplicates #20361.

Suggested consolidation

Keep #64456 open with a salvage path, consistent with the contributor keep_open review: move the optional human-mention guard before free-response and require_mention: false acceptance, preserve explicit bot-mention and reply-to-bot exceptions for mixed messages, expose the option through supported config.yaml configuration, and add regressions for free-response chats, captions, text_mention, and mixed mentions. The remaining closed or merged PRs are historical implementations, salvages, or duplicates and require no reopening; retain #3870, #12848, #13438, #19429, and #20416 as merged references.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    I64388(["issue #64388 (open)"])
    P64456["PR #64456 (open)"]
    P64456 -->|best fix| I64388
    class I64388 open
    class P64456 open
    class P64456 best
    class P64456 target
    click I64388 "https://github.com/NousResearch/hermes-agent/issues/64388"
    click P64456 "https://github.com/NousResearch/hermes-agent/pull/64456"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).

Cross-PR triage: Reviewed 19 pull requests and 6 issues in this complex. Each diff was read against this issue; Assessment working set: 140 kB of PR diffs, 49 kB of issue/PR text, 10 kB of discussion (20 comments), 26 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

area/config Config system, migrations, profiles 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-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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 option to ignore messages that @mention another human while still responding by default

5 participants