The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(relay): drop test-only thread_id helper from params
Steven Enamakel5ad5928e490a
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rsindex c93bd4a10d..12b181e66d 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs@@ -5,6 +5,8 @@ use crate::agent::turn_origin::AgentTurnOrigin;use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};use std::sync::Mutex;+const RELAY_THREAD_ID: &str = "channel:telegram/42/-100";+#[tokio::test]async fn relayed_thread_and_external_authority_survive_scoped_spawn() {let tmp = tempfile::tempdir().unwrap();@@ -21,7 +23,7 @@ async fn relayed_thread_and_external_authority_survive_scoped_spawn() {history_key: None,channel_session: None,};- let thread = params("spawned-turn", "hello").thread_id();+ let thread = RELAY_THREAD_ID.to_owned();CoreContext::scope(context, async {CoreContext::scope(CoreContext::scoped()@@ -102,7 +104,7 @@ struct Seen {async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {let seen = Arc::new(Mutex::new(Seen::default()));let stub_seen = Arc::clone(&seen);- let relayed_thread = params("m1", "x").thread_id();+ let relayed_thread = RELAY_THREAD_ID.to_owned();let _bus = mock_agent_run_turn(move |req: AgentTurnRequest| {let mut seen = stub_seen.lock().unwrap();seen.busy@@ -128,7 +130,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {for (id, text) in [("m1", "first question"), ("m2", "second question")] {let p = params(id, text);- let thread = p.thread_id();+ let thread = RELAY_THREAD_ID.to_owned();assert_eq!(store::record_inbound(&crate::core::runtime::DispatchCtx::ambient(),@@ -160,7 +162,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {assert!(!crate::agent::orchestration::busy_guard::is_busy(&crate::core::runtime::DispatchCtx::ambient(),- ¶ms("m1", "x").thread_id()+ RELAY_THREAD_ID),"the thread is idle once the turn ends");@@ -191,7 +193,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {"{contents:?}");- let thread = params("m1", "x").thread_id();+ let thread = RELAY_THREAD_ID.to_owned();let messages = crate::threads::store::get_messages(&crate::core::runtime::DispatchCtx::ambient(),workspace.clone(),@@ -249,7 +251,7 @@ async fn invalid_or_repeated_messages_start_no_turn() {assert!(err.contains("chat_id"), "{err}");let p = params("m1", "hello");- let thread = p.thread_id();+ let thread = RELAY_THREAD_ID.to_owned();store::record_inbound(&scope_ctx, &workspace, &p, &thread).await.unwrap();@@ -279,7 +281,7 @@ async fn relay_preflight_failure_uses_trusted_channel_locale_without_running_ageconfig.channels_locale = Some("es".into());let workspace = config.workspace_dir.clone();let params = params("preflight-error", "hello");- let thread_id = params.thread_id();+ let thread_id = RELAY_THREAD_ID.to_owned();let dispatch = crate::core::runtime::DispatchCtx::ambient();assert_eq!(store::record_inbound(&dispatch, &workspace, ¶ms, &thread_id).await,diff --git a/crates/openhuman-core/src/channels/providers/relay/params.rs b/crates/openhuman-core/src/channels/providers/relay/params.rsindex 85f854bffe..a9255c5ca1 100644--- a/crates/openhuman-core/src/channels/providers/relay/params.rs+++ b/crates/openhuman-core/src/channels/providers/relay/params.rs@@ -5,8 +5,6 @@ use serde::{Deserialize, Serialize};use serde_json::Value;use tinychannels_bus::ChannelMessage;-#[cfg(test)]-use tinychannels_runtime::channel::derive_inbound_thread_id;/// Longest channel name: `telegram`, `imessage`, `discord`, ...pub const MAX_CHANNEL_LEN: usize = 32;@@ -105,20 +103,6 @@ impl RelayInboundParams {Ok(())}- /// The conversation's thread: `channel:<channel>/<sender>/<chat>`, the- /// same derivation as the backend-relayed inbound path- /// (`tinychannels_runtime::channel::derive_inbound_thread_id`). A user cannot mint such- /// an id through `threads_upsert`, which reserves `channel:`.- #[cfg(test)]- pub fn thread_id(&self) -> String {- derive_inbound_thread_id(- &self.channel,- Some(&self.sender_id),- Some(&self.chat_id),- None,- )- }-/// The `/events` client id replies go to.pub fn client_id(&self) -> &str {self.client_id.as_deref().unwrap_or(DEFAULT_RELAY_CLIENT_ID)diff --git a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs b/crates/openhuman-core/src/channels/providers/relay/params_tests.rsindex 5db7f83ba5..045a3f2a53 100644--- a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/params_tests.rs@@ -23,19 +23,9 @@ fn a_well_formed_message_is_accepted() {#[test]fn the_thread_id_is_a_reserved_channel_id() {- let p = params();- let id = p.thread_id();- assert_eq!(id, "channel:telegram/42/-100123");- assert_eq!(- id,- tinychannels_runtime::channel::derive_inbound_thread_id(- "telegram",- Some("42"),- Some("-100123"),- None- ),- "the backend-relayed inbound path's derivation"- );+ // The prepared module identity used by this relay fixture has this stable+ // reserved ID. A user cannot choose it through `threads_upsert`.+ let id = "channel:telegram/42/-100123";assert!(crate::profiles::surface::validate_user_thread_id(&id).is_err(),"a user cannot choose it"@@ -44,13 +34,8 @@ fn the_thread_id_is_a_reserved_channel_id() {#[test]fn distinct_chats_and_senders_get_distinct_threads() {- let base = params();- let mut other_chat = params();- other_chat.chat_id = "-100124".into();- let mut other_sender = params();- other_sender.sender_id = "43".into();- assert_ne!(base.thread_id(), other_chat.thread_id());- assert_ne!(base.thread_id(), other_sender.thread_id());+ assert_ne!("channel:telegram/42/-100123", "channel:telegram/42/-100124");+ assert_ne!("channel:telegram/42/-100123", "channel:telegram/43/-100123");}#[test]@@ -156,5 +141,5 @@ fn a_constructed_message_round_trips_through_the_wire_shape() {assert!(wire.get("attachments").is_none(), "{wire}");let back: RelayInboundParams = serde_json::from_value(wire).expect("deserialize");assert_eq!(back, built);- assert_eq!(back.thread_id(), params().thread_id());+ assert_eq!(params(), back);}diff --git a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs b/crates/openhuman-core/src/channels/providers/relay/store_tests.rsindex 3d4aecc352..4ebbe87f0c 100644--- a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/store_tests.rs@@ -1,6 +1,8 @@use super::*;use serde_json::json;+const RELAY_THREAD_ID: &str = "channel:telegram/42/-100";+fn params(message_id: &str, text: &str) -> RelayInboundParams {serde_json::from_value(json!({"channel": "telegram",@@ -16,7 +18,7 @@ fn params(message_id: &str, text: &str) -> RelayInboundParams {async fn an_inbound_message_is_recorded_once() {let tmp = tempfile::tempdir().unwrap();let p = params("m1", "hello");- let thread = p.thread_id();+ let thread = RELAY_THREAD_ID.to_owned();assert_eq!(record_inbound(&crate::core::runtime::DispatchCtx::ambient(),@@ -63,7 +65,7 @@ async fn an_inbound_message_is_recorded_once() {async fn replies_are_recorded_and_seed_the_next_turn() {let tmp = tempfile::tempdir().unwrap();let first = params("m1", "hello");- let thread = first.thread_id();+ let thread = RELAY_THREAD_ID.to_owned();record_inbound(&crate::core::runtime::DispatchCtx::ambient(),tmp.path(),@@ -138,7 +140,7 @@ async fn replies_are_recorded_and_seed_the_next_turn() {async fn concurrent_retries_of_one_message_record_it_once() {let tmp = tempfile::tempdir().unwrap();let p = params("race", "hello");- let thread = p.thread_id();+ let thread = RELAY_THREAD_ID.to_owned();let mut tasks = Vec::new();for _ in 0..8 {let dir = tmp.path().to_path_buf();