sandbox-quantum / sandbox-quantum/switch
Telegram agent replies are dropped when the thread root is chat_id:message_id
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 646
- Forks
- 52
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 151
Description
Component
switch-core (control plane)
Version or commit
Tested locally with Switch core 0.23.0 and Switch Console 0.32.0.
What happened
These are codex generated, and the suggested fix is not tested, but sharing in case it is useful:
When an agent is mentioned in a Telegram group, Switch receives and processes the message, but the agent’s final response is not delivered back to Telegram.
Observed behavior:
- Add a Telegram bot to a group and connect that group as a Switch room.
- Add an agent to the room.
- Mention the agent in Telegram.
- The agent session starts, the working indicator appears and later clears, and the agent completes its response.
- No response appears in Telegram.
Switch logs show:
Ignoring unparseable Telegram thread root '<chat_id>:<message_id>'
The Telegram adapter appears to receive normal Switch message references in chat_id:message_id form, but attempts to parse the entire string as an integer when forming reply kwargs. This prevents the outbound reply from being sent.
Expected behavior: parse the message reference and use only the message_id portion as Telegram’s reply_to_message_id.
Suggested fix in switch_core/bridges/collaboration/telegram/adapter.py:
_chat_id, message_id = TelegramAdapter._parse_message_ref(thread_root_id)
root = int(message_id or thread_root_id)
Tested locally with Switch core 0.23.0 and Switch Console 0.32.0.
Steps to reproduce
- Start a local Switch instance and connect a Telegram bot.
- Create a Telegram group and add the bot as an administrator.
- Let Switch adopt the Telegram group as a room.
- Create an agent and add it to that room.
- In the Telegram group, send a message that mentions the agent.
- Wait for the agent to process and post its response.
Actual result
The agent processes the request, but no final reply appears in Telegram. Logs include:
Ignoring unparseable Telegram thread root '<chat_id>:<message_id>'
Expected result
The agent’s response should appear in the Telegram group, replying to the message that triggered it.
Logs or error output
Environment
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in switch_core/bridges/collaboration/telegram/adapter.py and trace how thread_root_id is parsed when forming the outbound Telegram reply. Reproduce the group-mention flow or inspect the logged unparseable thread root, then verify that the agent’s response appears in Telegram as a reply to the triggering message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100