Skip to content

Support multiple Telegram bots connecting to the same agent (same gateway, different sessions) using the same Telegram account. #8287

Description

@shaohq

Feature Description

Support multiple Telegram bots connecting to the same agent (same gateway, different sessions) using the same Telegram account.

Motivation

When working on complex tasks, users often need the same agent to work on multiple things in parallel. Currently the only option is /background, which has these limitations:

  1. Complex task delivery is cumbersome — passing detailed, multi-step instructions to /background is awkward and error-prone
  2. No mid-task interaction — once a background job starts, you cannot intervene, ask questions, or provide feedback until it completes
  3. Single-threaded queue — multiple background jobs still run sequentially, not in parallel

Multiple parallel sessions (via multiple bots) would allow the agent to simultaneously work on unrelated tasks, each with full interactive feedback capability.

Proposed Solution

Allow multiple Telegram bots under the same account to connect to the same gateway and agent, each with its own independent session. From the user's perspective, they would talk to "Bot A" for Task 1 and "Bot B" for Task 2, while both are powered by the same underlying agent with shared context (optional — could also be isolated per bot).

Potential implementation approaches:

  • Session key = (user_id, bot_token) instead of just user_id, allowing the same user to have multiple concurrent sessions per bot
  • Gateway routing based on bot token to dispatch to the correct session
  • Optional shared memory/context between sessions for collaborative tasks

Alternatives Considered

  • /background with job queue — only sequential, no mid-task interactivity
  • Multiple separate agents — each is isolated, no shared context, harder to manage
  • Threaded conversations in a single bot — adds significant UI and state complexity

Scope / Effort Estimate

Medium — primarily affects the gateway's session routing layer and the Telegram platform adapter. Session isolation is already partially implemented.

Additional Context

This is somewhat analogous to how IRC bouncers or modern Slack apps handle multi-channel concurrency, but simpler since sessions are stateless per-message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/sessionsSession lifecycle, resume, persistence, historycomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions