ductor icon indicating copy to clipboard operation
ductor copied to clipboard

[Feature]: Telegram Topic-Based Session and Workspace Isolation

Open bribeck opened this issue 9 months ago • 1 comments

Problem or motivation

Currently, Ductor users must either use random Named Session codenames (e.g., @blueant) or create entirely separate Sub-Agents to achieve context isolation. While effective, this creates friction when organizing a single bot into multiple "workstreams" or "personas" (e.g., System Admin, Personal Projects, Family Logistics).

Proposed solution

Describe the solution you'd like I would like to see native support for Telegram Topic Isolation.

Specifically:

  1. Composite Session Keys: The SessionManager should optionally use a composite key of chat_id:thread_id. When a message is received from a specific Telegram Topic, Ductor should automatically route it to a session isolated to that thread.
  2. Workspace Redirection: Ideally, each Topic could be mapped to an isolated working directory (e.g., workspace/topics/[thread_id]/) to prevent file-system context pollution between different projects.
  3. Automatic Alias: Messages sent within a topic should not require the @session_name prefix; the Topic ID itself should act as the implicit session handle.

Describe alternatives you've considered

  • Sub-Agents: Requires multiple Telegram bot tokens and can be heavy for simple categorization.
  • Named Sessions: The random codenames are difficult to remember and map to specific project topics.

Additional context Implementing this would allow a single Ductor instance to act as a highly organized command center, where switching between "System Updates" and "Development" is as simple as clicking a different tab in the Telegram group.

Alternatives considered

No response

Before submitting

  • [x] I have searched existing issues and feature requests for duplicates.

bribeck avatar Mar 02 '26 18:03 bribeck

Hey @bribeck! Great news — v0.12.0 ships with full topic-based session isolation, covering points 1 and 3 from your proposal:

What's implemented:

  • Composite Session Keys — Sessions now use a SessionKey(chat_id, topic_id) internally. When you send a message in a Telegram forum topic, ductor automatically routes it to a session isolated to that topic. No prefix needed, no manual setup.
  • Automatic Alias — Each topic acts as its own implicit session. Just type in the topic and you're in context. /new resets only that topic's session. /status shows per-topic state.
  • Per-topic model/provider selection — You can even switch models per topic (e.g., Claude in "Development", Codex in "System Admin").
  • Topic name cache — Topic names show up in session lists, status, and logs for easy identification.
  • Task routing — Background tasks started from a topic return their results back to that same topic.

What's not yet implemented:

  • Workspace isolation (point 2) — Each topic still shares the same working directory. Mapping topics to isolated workspaces (e.g., workspace/topics/<thread_id>/) is a natural next step, but not part of this release. We'll track that separately if there's interest.

Relevant commits: fd7e208, 2cd524e, 067c75f, d2d533f, 879d774, 0487175

Closing this as the core feature is live. If workspace isolation is important to you, feel free to open a follow-up issue for that specifically!

PleasePrompto avatar Mar 04 '26 08:03 PleasePrompto