Skip to content

feat(gateway): Telegram reply threading modes + forum topic fix#855

Closed
raulvidis wants to merge 2 commits intoNousResearch:mainfrom
raulvidis:feature/telegram-reply-to-mode-clean
Closed

feat(gateway): Telegram reply threading modes + forum topic fix#855
raulvidis wants to merge 2 commits intoNousResearch:mainfrom
raulvidis:feature/telegram-reply-to-mode-clean

Conversation

@raulvidis
Copy link

@raulvidis raulvidis commented Mar 10, 2026

Summary

  • Fix forum topic replies: Responses now land in the correct Telegram forum topic thread. The base dispatcher (_process_message_background) properly passes thread_id via metadata to send().
  • Configurable reply threading: New reply_to_mode setting (off/first/all) controls whether multi-chunk replies thread to the original message. Configurable via reply_to_mode in platform config or TELEGRAM_REPLY_TO_MODE env var. Default first preserves existing behavior.

Test plan

  • 25 unit tests covering all reply modes, config serialization, env var overrides, and edge cases
  • Manual testing on live Telegram bot — confirmed forum topic replies work correctly
  • Verified default behavior (first mode) is unchanged from previous behavior

🤖 Generated with Claude Code

opencode and others added 2 commits March 10, 2026 21:52
Adds configurable threading behavior for multi-chunk Telegram responses:

- reply_to_mode: 'off' - Never thread replies
- reply_to_mode: 'first' - Only first chunk threads (default)
- reply_to_mode: 'all' - All chunks thread to original message

Useful for bots in busy groups where threaded replies keep
conversations organized.

Configurable via gateway.json or TELEGRAM_REPLY_TO_MODE env var.

Based on OpenClaw's ReplyToMode implementation.
- Fix forum topic replies: base.py _process_message_background() now
  passes event.source.thread_id via metadata to send(), so responses
  land in the correct Telegram forum topic thread
- Remove unused _delivery_progress dict from TelegramAdapter
- Remove unused chat_id param from _should_thread_reply()
- Fix tests to use numeric IDs (matching real Telegram IDs)
- Remove redundant @pytest.mark.asyncio (asyncio_mode=auto handles it)
- Add TestEnvVarOverride tests for TELEGRAM_REPLY_TO_MODE env var

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
teknium1 pushed a commit that referenced this pull request Mar 11, 2026
Add configurable reply_to_mode for Telegram multi-chunk replies:
- off: never thread replies to original message
- first: only first chunk threads (default, preserves current behavior)
- all: all chunks thread to original message

Configurable via reply_to_mode in platform config or TELEGRAM_REPLY_TO_MODE
env var.

Cherry-picked from PR #855 by raulvidis, rebased onto current main.
Dropped asyncio_mode=auto pyproject.toml change, added @pytest.mark.asyncio
decorators, fixed test IDs to use numeric strings.

Co-authored-by: Raul <77628552+raulvidis@users.noreply.github.com>
@teknium1
Copy link
Contributor

Cherry-picked into PR #956 with contributor credit preserved (--author + Co-authored-by). Thank you @raulvidis!

Changes from the original PR:

  • Forum topic fix was already working on main (base.py already passes thread_id via metadata) — skipped
  • Dropped asyncio_mode = "auto" from pyproject.toml (would affect the entire test suite)
  • Added @pytest.mark.asyncio decorators to async tests instead
  • Fixed test IDs to use numeric strings (matching real Telegram IDs)

@teknium1 teknium1 closed this Mar 11, 2026
@raulvidis
Copy link
Author

Thanks for the merge! I'll keep contributing — aiming to bring the same quality with every PR 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants