Skip to content

fix(telegram): normalize forum topics and bot command mentions - #18913

Closed
nocturnum91 wants to merge 1 commit into
NousResearch:mainfrom
nocturnum91:fix/telegram-forum-topic-bot-command-mentions
Closed

fix(telegram): normalize forum topics and bot command mentions#18913
nocturnum91 wants to merge 1 commit into
NousResearch:mainfrom
nocturnum91:fix/telegram-forum-topic-bot-command-mentions

Conversation

@nocturnum91

@nocturnum91 nocturnum91 commented May 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Telegram gateway group/forum edge cases so General-topic forum messages and bot-command mentions are routed and gated consistently.

Related Issue

N/A.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Normalize Telegram forum General-topic messages so message_thread_id=None maps to thread id "1" where topic routing needs it.
  • Fix bot-command mention handling in groups and forum topics.
  • Preserve non-forum group reply-derived thread IDs without incorrectly treating them as topic/session routing IDs.
  • Update Telegram group/topic gating helpers and regression tests for forum and non-forum behavior.

How to Test

  1. Run Telegram gateway focused tests for forum topic normalization and bot-command mentions.
  2. Verify General-topic forum messages map to thread id "1" for topic-aware routing.
  3. Verify non-forum group replies do not create unintended topic/session routing.
  4. Run a read-only Codex review of the final branch delta.

Verification performed during refresh:

  • uv run --extra dev pytest ... focused Telegram tests: 104 passed.
  • Read-only Codex review: VERDICT: CLEAN.
  • Branch was rebased onto current main and updated with --force-with-lease.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Note: I ran focused/regression tests locally for the changed Telegram gateway behavior and am relying on GitHub Actions for the full matrix.

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A — this PR does not add a skill.

Screenshots / Logs

N/A. Relevant verification is in local focused test output, Codex review logs, and GitHub Actions checks.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 2, 2026
@nocturnum91
nocturnum91 force-pushed the fix/telegram-forum-topic-bot-command-mentions branch 5 times, most recently from 214ff2e to c1ba034 Compare May 6, 2026 05:01
@nocturnum91
nocturnum91 force-pushed the fix/telegram-forum-topic-bot-command-mentions branch 11 times, most recently from 5b54ec7 to a47d3b3 Compare May 13, 2026 17:33
@nocturnum91
nocturnum91 force-pushed the fix/telegram-forum-topic-bot-command-mentions branch 8 times, most recently from f8a1476 to a8134c0 Compare May 19, 2026 12:32
@nocturnum91
nocturnum91 force-pushed the fix/telegram-forum-topic-bot-command-mentions branch from a8134c0 to 6eb8ad5 Compare May 19, 2026 14:11
@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state 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 Jun 29, 2026
@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Merged via #56109#56109

Your commit was cherry-picked onto current main with your authorship preserved in git log (merge commit cc1e4c3).

Since this branch was opened, two of the three parts had already landed on main independently:

Telegram also moved from gateway/platforms/telegram.py to plugins/platforms/telegram/adapter.py. The salvage carries the one remaining un-merged delta — your _effective_message_thread_id() helper — and routes both the group gate and the event builder through it, so gating and session routing can no longer diverge (a non-forum reply's anchor id is no longer dropped by ignored_threads or read as a topic under allowed_topics). Regression tests for both cases included. Thanks!

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 P1 High — major feature broken, no workaround 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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants