Describe the bug
In Telegram forum groups, responses sometimes leak into the wrong thread (or General). This happens because gateway/run.py fails to pass the correct thread_id in the metadata when sending the final response chunk or when streaming falls back to a single adapter.send() call.
To Reproduce
- Use Hermes in a Telegram supergroup with Topics enabled.
- Send a message in a specific topic.
- The final
first_response (around line 7332) uses getattr(event, "metadata", None) instead of explicitly passing source.thread_id.
Expected behavior
The final response should stay in the original thread by explicitly checking source.thread_id.
Code snippet
In gateway/run.py around line 7332:
# Current:
await adapter.send(source.chat_id, first_response,
metadata=getattr(event, "metadata", None))
# Expected:
_thread_meta = {"thread_id": source.thread_id} if source.thread_id else getattr(event, "metadata", None)
await adapter.send(source.chat_id, first_response, metadata=_thread_meta)
Describe the bug
In Telegram forum groups, responses sometimes leak into the wrong thread (or General). This happens because
gateway/run.pyfails to pass the correctthread_idin themetadatawhen sending the final response chunk or when streaming falls back to a singleadapter.send()call.To Reproduce
first_response(around line 7332) usesgetattr(event, "metadata", None)instead of explicitly passingsource.thread_id.Expected behavior
The final response should stay in the original thread by explicitly checking
source.thread_id.Code snippet
In
gateway/run.pyaround line 7332: