Skip to content

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

fix(channels): prefer reply_to_id over thread_ts for reply targeting

Steven Enamakelf177e531f818
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index b457ce8eab..7c0a686c7c 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);
- // 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();
+ // 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());
let reply_recipient = reset_scope
.as_ref()
.map(|scope| scope.conversation.id.clone())
@@ -255,8 +255,8 @@ where
return true;
}
};
- if clear_history && reset_history().await.is_err() {
- tracing::warn!("channel durable history reset failed");
+ if clear_history && let Err(error) = reset_history().await {
+ tracing::warn!(%error, "channel durable history reset failed");
if let Some(channel) = target_channel {
let copy = crate::channels::failure_copy::generic_failure(ctx.config.as_deref());
let _ = channel
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index d2bd6ff735..abc2086a5c 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -120,6 +120,7 @@ async fn handle_linked_runtime_command(
use tinychannels_bus::module_remote::RemoteSessionScope;
ctx.channels_by_name = linked.channels();
+ ctx.module_objects = linked.module_objects();
let _core =
crate::channels::runtime::test_support::bind_test_core_context(ctx, linked.config());
let account_id = linked
diff --git a/crates/openhuman-core/src/channels/routes_tests_telegram.rs b/crates/openhuman-core/src/channels/routes_tests_telegram.rs
index 844f7fc990..375516a855 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: None,
+ reply_to_id: Some("42".into()),
topic_id: None,
id: "1".into(),
sender: "alice".into(),
@@ -18,7 +18,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
content: "/new".into(),
channel: "telegram".into(),
timestamp: 0,
- thread_ts: Some("42".into()),
+ thread_ts: None,
sender_name: None,
};
assert!(handle_linked_runtime_command(&mut ctx, &new_msg, Some(&channel), &linked, None).await);
@@ -31,7 +31,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
},
);
- let subscriber = ChannelTurnStateSubscriber::with_config(Arc::new(linked.config().clone()));
+ let subscriber = ChannelTurnStateSubscriber::new(workspace.clone());
subscriber
.handle(&DomainEvent::ChannelMessageReceived {
channel: "telegram".into(),
@@ -39,14 +39,14 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
sender: "alice".into(),
reply_target: "chat-remote".into(),
content: "work".into(),
- thread_ts: Some("42".into()),
+ thread_ts: None,
inbound_envelope: None,
workspace_dir: workspace.clone(),
})
.await;
let status_msg = ChannelMessage {
- reply_to_id: None,
+ reply_to_id: Some("42".into()),
topic_id: None,
id: "3".into(),
sender: "alice".into(),
@@ -54,7 +54,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
content: "/status".into(),
channel: "telegram".into(),
timestamp: 0,
- thread_ts: Some("42".into()),
+ thread_ts: None,
sender_name: None,
};
assert!(
@@ -62,7 +62,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
);
let sessions_msg = ChannelMessage {
- reply_to_id: None,
+ reply_to_id: Some("42".into()),
topic_id: None,
id: "4".into(),
sender: "alice".into(),
@@ -70,7 +70,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
content: "/sessions".into(),
channel: "telegram".into(),
timestamp: 0,
- thread_ts: Some("42".into()),
+ thread_ts: None,
sender_name: None,
};
assert!(
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index fd8c36581b..4d852782a6 100644
--- a/crates/openhuman-core/src/channels/runtime/test_support.rs
+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs
@@ -148,6 +148,12 @@ impl LinkedTelegramRuntime {
self.runtime.channels()
}
+ pub(crate) fn module_objects(
+ &self,
+ ) -> Arc<HashMap<String, tinybus::module::ModuleObjectClient>> {
+ self.runtime.module_objects()
+ }
+
pub(crate) fn config(&self) -> &crate::config::Config {
&self.config
}