hermes - 💡(How to fix) Fix Feature: Telegram forum topic identity routing — each topic acts as a different agent

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

I run a multi-agent system (AgentOS) with 5 specialist agents — Scout (research), Scribe (writing), Assistant (personal ops), Dev (coding), Ops (infrastructure). I want each Telegram forum topic to feel like I'm talking directly to that agent, not to a dispatcher who then delegates.

Implementation (source patch)

Two source files were patched to achieve this:

Code Example

for _line in trimmed_ephemeral.split("\n"):
    if _line.startswith("# ") and not _line.startswith("## "):
        _h1_match = _line.strip("# ")
        break
if _h1_match:
    _existing_soul = load_soul_md()
    if _existing_soul and _existing_soul in effective_system:
        effective_system = effective_system.replace(
            _existing_soul, trimmed_ephemeral, 1
        )

---

telegram:
  extra:
    thread_sessions_per_user: true
  channel_prompts:
    'THREAD_ID': |
      # Agent NameRole
      ...full agent identity...

---

telegram:
  channel_prompts:
    'THREAD_ID':
      prompt: |
        # Agent Identity...
      replace_identity: true
RAW_BUFFERClick to expand / collapse

Problem

When using Telegram forum topics for a multi-agent system, each topic should act as a different agent with its own identity, persona, and behavior. Currently, all messages in a group go to the same agent session regardless of which forum topic they originate from.

Use Case

I run a multi-agent system (AgentOS) with 5 specialist agents — Scout (research), Scribe (writing), Assistant (personal ops), Dev (coding), Ops (infrastructure). I want each Telegram forum topic to feel like I'm talking directly to that agent, not to a dispatcher who then delegates.

Desired Behavior

  1. Each Telegram forum topic has its own isolated session
  2. Each topic gets its own system prompt identity — the agent "becomes" the specialist for that topic
  3. The General topic remains the coordinator/orchestrator

Implementation (source patch)

Two source files were patched to achieve this:

1. agent/conversation_loop.py (line ~966)

The ephemeral prompt (containing the channel_prompt) is currently appended after the cached SOUL.md identity. The patch changes the logic so that when the ephemeral prompt contains an H1 heading, it replaces the SOUL.md portion:

for _line in trimmed_ephemeral.split("\n"):
    if _line.startswith("# ") and not _line.startswith("## "):
        _h1_match = _line.strip("# ")
        break
if _h1_match:
    _existing_soul = load_soul_md()
    if _existing_soul and _existing_soul in effective_system:
        effective_system = effective_system.replace(
            _existing_soul, trimmed_ephemeral, 1
        )

2. agent/chat_completion_helpers.py (line ~1291)

Same logic applied to the secondary code path.

3. Configuration

telegram:
  extra:
    thread_sessions_per_user: true
  channel_prompts:
    'THREAD_ID': |
      # Agent Name — Role
      ...full agent identity...

Edge Cases & Pitfalls

  1. Session context wraps channel_prompt: The gateway prepends session context before the channel_prompt, so detection must scan line-by-line (not startswith).

  2. Local import breaks module: Adding import logging inside a function where logging.getLogger() is used elsewhere causes UnboundLocalError.

  3. Stale .pyc files: Multiple Python versions leave stale bytecode.

  4. File ownership on write: write_file/yaml.dump creates files as root with 600 perms. Gateway can't read them, falls back to hardcoded defaults.

  5. Existing session history: Pre-patch sessions have old identity in history. /new resolves it.

  6. Surviving updates: hermes update overwrites patched source files.

Feature Request

Native config-driven support rather than a source patch:

telegram:
  channel_prompts:
    'THREAD_ID':
      prompt: |
        # Agent Identity...
      replace_identity: true

Or a dedicated topic_agents: section mapping topics to personas and toolsets.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Feature: Telegram forum topic identity routing — each topic acts as a different agent