Skip to content

feat(telegram): per-topic skill binding and auto-discovery for group forums#5489

Open
willy-scr wants to merge 2 commits into
NousResearch:mainfrom
willy-scr:feature/group-topic-skill-binding
Open

feat(telegram): per-topic skill binding and auto-discovery for group forums#5489
willy-scr wants to merge 2 commits into
NousResearch:mainfrom
willy-scr:feature/group-topic-skill-binding

Conversation

@willy-scr

Copy link
Copy Markdown
Contributor

Summary

Adds native support for per-topic skill binding and automatic topic discovery in Telegram group forum (supergroup) chats. Closes #4622, Closes #3716

What Changed

gateway/platforms/telegram.py (+66 lines):

Skill Binding

  1. Config Loading (__init__) — Reads group_topics from platforms.telegram.extra config
  2. _get_group_topic_info() — Looks up topic config by chat_id + thread_id
  3. _reload_group_topics_from_config() — Hot-reloads group_topics from config.yaml without restart
  4. _build_message_event() branch — Resolves group topic skill binding and passes as auto_skill

Auto-Discovery (Lifecycle Events)

  1. _persist_group_topic() — Auto-registers new topics to config.yaml
  2. _persist_group_topic_edit() — Handles renames and close/reopen state
  3. _build_message_event() lifecycle handlers:
    • forum_topic_created — auto-persist new topic with name + thread_id + icon
    • forum_topic_edited — update topic name in config
    • forum_topic_closed — mark topic as closed
    • forum_topic_reopened — mark topic as reopened

gateway/run.py (+1/-1):

  • Fix metadata source: use message instead of event for first-response send

Key Features

  • Single bot, multiple roles per group
  • Auto-discovery — new topics register automatically, no manual config
  • Full lifecycle — create, rename, close, reopen all tracked
  • Hot-reloadable — add topics to config.yaml without restart
  • Zero breaking changes — fully backward compatible
  • Mirrors existing dm_topics pattern for consistency

Testing

  • Messages in configured topic trigger correct skill loading
  • Messages in unconfigured topics use default behavior
  • Hot-reload works without gateway restart
  • Multiple groups with different configs work independently
  • New topic creation auto-registers to config.yaml
  • Topic rename updates config.yaml
  • Topic close/reopen tracked in config
  • Backward compatible: no config = no change

@willy-scr willy-scr force-pushed the feature/group-topic-skill-binding branch from 0ff85e4 to 2ca1920 Compare April 6, 2026 10:19
Akah-dev added 2 commits April 9, 2026 17:41
…forums

Adds native support for per-topic skill binding in Telegram group forum
chats, with automatic topic discovery via lifecycle events.

Skill binding:
- Load group_topics config from platforms.telegram.extra
- _get_group_topic_info() resolves skill by chat_id + thread_id
- _reload_group_topics_from_config() hot-reloads without restart
- _build_message_event() passes auto_skill for topic-routed messages

Auto-discovery (lifecycle events):
- forum_topic_created → auto-persist new topic to config.yaml
- forum_topic_edited → update topic name in config
- forum_topic_closed/reopened → track open/closed state
- _persist_group_topic() registers new topics (skips duplicates)
- _persist_group_topic_edit() handles renames and state changes

Mirrors the existing dm_topics pattern. Fully backward compatible.

Closes NousResearch#4622
Closes NousResearch#3716
…ponse

The _run_agent method references 'event' which is not in scope when
sending the first response before processing a queued follow-up message.
This causes NameError and the response fails to deliver to the correct
chat/topic.

Fix: use 'message' parameter which is already in scope and contains
the metadata needed for proper routing.
@willy-scr willy-scr force-pushed the feature/group-topic-skill-binding branch from 2ca1920 to a551f99 Compare April 9, 2026 09:42
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter comp/gateway Gateway runner, session dispatch, delivery labels May 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #5488 (companion fix for forum topic service message handler registration).

2 similar comments
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #5488 (companion fix for forum topic service message handler registration).

@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #5488 (companion fix for forum topic service message handler registration).

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 type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Handle forum_topic_created events to auto-discover new forum threads Feature: Per-Topic Role/Skill Binding for Telegram Group Forum Topics

3 participants