Skip to content

[Feature] Map Telegram forum topics to different agent profiles under a single bot token #4321

@SHL0MS

Description

@SHL0MS

Problem

Users running Hermes in a Telegram group with forum topics want different agent profiles (personality, model, system prompt, toolsets) per topic — without creating a separate bot for each profile.

Example: a team group where Topic A is handled by a coding assistant profile and Topic B by a research assistant profile, both using the same bot token.

Current behavior

The Telegram adapter handles forum topics (telegram.py:2088-2090 discovers topic creation), and sessions are already scoped per-chat. But there is no mechanism to map a message_thread_id (topic ID) to a specific agent profile. All topics use the same agent configuration.

Suggested design

Add a topic_profiles mapping in the Telegram platform config:

platforms:
  telegram:
    token: "BOT_TOKEN"
    topic_profiles:
      "12345":          # message_thread_id for Topic A
        personality: "coding-assistant"
        model: "anthropic/claude-sonnet-4"
        toolsets: ["terminal", "file", "web"]
      "67890":          # message_thread_id for Topic B
        personality: "research-analyst"
        model: "openrouter/google/gemini-3-flash"
        toolsets: ["web"]
    # Default profile for topics not in the map
    personality: "general"

The gateway would resolve the profile at message intake time (_build_message_event or handle_message) and pass it through to the agent session.

Complexity

Medium. The gateway already has per-session agent caching (_agent_cache). The change is:

  1. Extract message_thread_id from the Telegram update (already available)
  2. Look up the topic profile in config
  3. Pass profile overrides (model, personality, toolsets) to the agent constructor

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions