Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(channels): use thread_ts for telegram reply targeting

Steven Enamakel5bb60b57407b
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index 7c0a686c7c..98d428150a 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -168,10 +168,10 @@ where
return false;
}
let current = get_route_selection(ctx, sender_key);
- // The prepared envelope keeps reply authority separately from its
- // conversation/topic reference. `SendMessage::thread_ts` is the legacy
- // owner-adapter field that TinyChannels maps to `reply_to_id`.
- let reply_thread = msg.reply_to_id.clone().or_else(|| msg.thread_ts.clone());
+ // Telegram's legacy `thread_ts` is the inbound provider message id used
+ // for reply targeting; forum topic routing is already encoded in
+ // `reply_target` and must not be reused as a reply-to id.
+ let reply_thread = msg.thread_ts.clone();
let reply_recipient = reset_scope
.as_ref()
.map(|scope| scope.conversation.id.clone())
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index eaea7dfd87..44a698f5ac 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -145,6 +145,7 @@ async fn handle_linked_runtime_command(
id: canonical_conversation_id
.unwrap_or(&msg.reply_target)
.to_owned(),
+ thread_id: msg.thread_ts.clone(),
topic_id: msg.topic_id.clone(),
..Default::default()
},
diff --git a/crates/openhuman-core/src/channels/routes_tests_telegram.rs b/crates/openhuman-core/src/channels/routes_tests_telegram.rs
index 375516a855..1f7356f6e2 100644
--- a/crates/openhuman-core/src/channels/routes_tests_telegram.rs
+++ b/crates/openhuman-core/src/channels/routes_tests_telegram.rs
@@ -10,7 +10,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
let sender_key = "telegram_alice_chat-remote";
let new_msg = ChannelMessage {
- reply_to_id: Some("42".into()),
+ reply_to_id: None,
topic_id: None,
id: "1".into(),
sender: "alice".into(),
@@ -19,6 +19,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
channel: "telegram".into(),
timestamp: 0,
thread_ts: None,
+ topic_id: Some("42".into()),
sender_name: None,
};
assert!(handle_linked_runtime_command(&mut ctx, &new_msg, Some(&channel), &linked, None).await);
@@ -46,7 +47,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
.await;
let status_msg = ChannelMessage {
- reply_to_id: Some("42".into()),
+ reply_to_id: None,
topic_id: None,
id: "3".into(),
sender: "alice".into(),
@@ -55,6 +56,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
channel: "telegram".into(),
timestamp: 0,
thread_ts: None,
+ topic_id: Some("42".into()),
sender_name: None,
};
assert!(
@@ -62,7 +64,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
);
let sessions_msg = ChannelMessage {
- reply_to_id: Some("42".into()),
+ reply_to_id: None,
topic_id: None,
id: "4".into(),
sender: "alice".into(),
@@ -71,6 +73,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
channel: "telegram".into(),
timestamp: 0,
thread_ts: None,
+ topic_id: Some("42".into()),
sender_name: None,
};
assert!(
@@ -97,7 +100,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
assert!(sent[2].content.contains("→ `Telegram"));
assert!(
sent.iter()
- .all(|message| message.thread_ts.as_deref() == Some("42"))
+ .all(|message| message.topic_id.as_deref() == Some("42"))
);
}
@@ -117,9 +120,8 @@ async fn handle_runtime_command_telegram_new_uses_module_storage() {
topic_id: Some("42".into()),
id: "100".into(),
sender: "alice".into(),
- // This fixture supplies the same canonical conversation reference the
- // inbound module preparation boundary provides to command handling.
- reply_target: "-200:42".into(),
+ // The module prepares the chat and topic as distinct canonical fields.
+ reply_target: "-200".into(),
content: "/new".into(),
channel: "telegram".into(),
timestamp: 0,