Skip to content

Feature: Per-topic/per-group system prompt (or SOUL.md) binding for Telegram #5195

@leeoxi82

Description

@leeoxi82

Summary

Allow binding a custom system_prompt (or soul override) to individual Telegram DM topics and group forum topics, so each topic can have its own agent personality/instructions without affecting other topics.

Current Behavior

  • SOUL.md is global — all chats share the same identity
  • agent.system_prompt in config.yaml is global
  • AGENTS.md is based on filesystem TERMINAL_CWD, not per-chat
  • /personality is session-level and must be manually switched
  • Topics can only bind a skill as a workaround, but that's a hack — skills are injected into the user message, not the system prompt, and only on new sessions

Proposed Behavior

Add an optional system_prompt field to dm_topics and group_topics config:

platforms:
  telegram:
    extra:
      dm_topics:
      - chat_id: 123456789
        topics:
        - name: Code Review
          system_prompt: |
            You are a senior code reviewer. Be concise, focus on bugs and security issues.
          # skill can coexist
          skill: code-review
      - chat_id: -1001234567890
        group_topics:
        topics:
        - thread_id: 5
          system_prompt: "你是代码审查专家,用中文回复"
        - thread_id: 12
          system_prompt: "You are a research assistant specialized in ML papers"

The topic-level system_prompt would be injected into the system prompt stack after SOUL.md (layer 2 in _build_system_prompt), so it supplements but doesn't replace the global identity.

Use Cases

  • Team supergroup with different topic personas (Engineering, Research, Support)
  • DM topics for different projects with domain-specific instructions
  • Different language preferences per topic
  • Different output format/style per topic without creating hacky skills

Implementation Notes

  • Add topic_system_prompt: Optional[str] to MessageEvent (base.py)
  • Read system_prompt from topic config in Telegram adapter's _parse_message
  • Inject in _build_system_prompt after SOUL.md, before tool guidance
  • Apply on every message (not just new sessions), since it's part of the system prompt stack
  • Consider adding a soul field as an alternative that fully replaces SOUL.md for that topic

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/featureNew feature or request

    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