Skip to content

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

refactor(core): update message handling in relay provider

Steven Enamakel131af66946aa
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index 907b7323d6..8b8927588f 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -56,16 +56,7 @@ impl LegacyHistoryImport {
self.limit,
)
.await?;
- Ok(rows
- .into_iter()
- .map(|row| match row.role.as_str() {
- "user" => tinyagents_session::transcript::TranscriptMessage::user(row.content),
- "assistant" => {
- tinyagents_session::transcript::TranscriptMessage::assistant(row.content)
- }
- _ => unreachable!("prior_turns only returns user and assistant rows"),
- })
- .collect())
+ Ok(rows)
}
}
diff --git a/crates/openhuman-core/src/channels/providers/relay/store.rs b/crates/openhuman-core/src/channels/providers/relay/store.rs
index 504a12bbaf..28b018fd78 100644
--- a/crates/openhuman-core/src/channels/providers/relay/store.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/store.rs
@@ -15,7 +15,6 @@ type ThreadLocks = Mutex<HashMap<(PathBuf, String), Arc<tokio::sync::Mutex<()>>>
use chrono::Utc;
use serde_json::json;
-use tinychannels_runtime::context::ChatMessage;
use super::params::RelayInboundParams;
use crate::threads::store::blocking as conversations;
@@ -156,7 +155,7 @@ pub async fn prior_turns(
thread_id: &str,
message_id: &str,
limit: usize,
-) -> Result<Vec<ChatMessage>, String> {
+) -> Result<Vec<tinyagents_session::transcript::TranscriptMessage>, String> {
let current = inbound_message_id(message_id);
let messages = conversations::get_messages(
ctx.clone(),
@@ -170,13 +169,20 @@ pub async fn prior_turns(
}
/// `messages` up to (not including) the one with id `current`, as history.
-fn to_history(messages: &[ConversationMessage], current: &str) -> Vec<ChatMessage> {
+fn to_history(
+ messages: &[ConversationMessage],
+ current: &str,
+) -> Vec<tinyagents_session::transcript::TranscriptMessage> {
messages
.iter()
.take_while(|message| message.id != current)
.filter_map(|message| match message.sender.as_str() {
- "user" => Some(ChatMessage::user(&message.content)),
- "assistant" => Some(ChatMessage::assistant(&message.content)),
+ "user" => Some(tinyagents_session::transcript::TranscriptMessage::user(
+ &message.content,
+ )),
+ "assistant" => Some(tinyagents_session::transcript::TranscriptMessage::assistant(
+ &message.content,
+ )),
_ => None,
})
.collect()
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
index 03e50f4beb..5d542132aa 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
@@ -11,10 +11,7 @@ pub(super) use tinychannels::runtime::select_acknowledgment_reaction;
pub(super) fn log_worker_join_result(result: Result<(), tokio::task::JoinError>) {
if let Err(error) = result {
- tracing::warn!(
- "{}",
- tinychannels_runtime::context::worker_crash_message(&error)
- );
+ tracing::warn!("Channel message worker crashed: {error}");
}
}
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas.rs b/crates/openhuman-core/src/modules/storage_grant_schemas.rs
index 918e081191..ceed8e3730 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas.rs
@@ -31,7 +31,7 @@ struct Row {
const ROWS: [Row; 6] = [
Row {
- module: tinychannels::MODULE_ID,
+ module: "tinychannels",
owner: "channels",
secrets: &[],
},
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index 474845b173..ce7509047b 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -33,6 +33,7 @@ use tinybus::EventHandler;
use tinybus::SubscriptionHandle;
use tinychannels_bus::ChannelMessage;
#[cfg(test)]
+#[cfg(test)]
use tinychannels_runtime::context::conversation_history_key;
use super::{