[codex] add telegram topic routing config and thread-aware chat routing#226
Merged
[codex] add telegram topic routing config and thread-aware chat routing#226
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds opt-in Telegram topic-based routing so forum threads can keep isolated session/memory context.
Closes #220.
Problem
In Telegram supergroups with forum topics, MicroClaw previously keyed Telegram sessions only by
chat_id.That merged all topics in the same group into one conversation state.
User impact:
Root Cause
external_chat_idfor Telegram was always the raw Telegramchat_id, andmessage_thread_idwas ignored for session routing.Changes
channels.telegram.topic_routing.enabled(defaultfalse)external_chat_idas{chat_id}:{thread_id}whenmessage_thread_idexists and routing is enabled{chat_id}behavior when disabled or when no thread id is presentexternal_chat_idshapes:{chat_id}{chat_id}:{thread_id}message_thread_idValidation
Executed:
cargo test -p microclaw --lib channels::telegram::tests::test_build_telegram_runtime_contexts_topic_routing_enabled -- --nocapturecargo test -p microclaw --lib channels::telegram::tests::test_telegram_external_chat_id_topic_routing -- --nocapturecargo test -p microclaw --lib tools::send_message::tests::test_send_message_web_caller_cross_chat_denied -- --nocaptureAll passed.
Topic Routing Config Priority
Telegram topic routing now supports both channel-level default and per-account override.
Priority order:
channels.telegram.accounts.<account_id>.topic_routing.enabled(highest)channels.telegram.topic_routing.enabledfalse(implicit default)This allows gradual rollout by account while keeping backward compatibility.
Migration Examples
Channel-wide enable:
Mixed mode (channel default + account override):
In the mixed mode above:
mainfollows channel default (false)opsuses account override (true)