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(channels): store conversation history as bus chat messages
Steven Enamakel3bb9cc5afeb2
diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rsindex dd555bf5e5..3dc9763786 100644--- a/crates/openhuman-core/src/channels/context_tests.rs+++ b/crates/openhuman-core/src/channels/context_tests.rs@@ -89,18 +89,18 @@ fn clear_and_compact_sender_history_update_cached_messages() {let ctx = runtime_context();let sender = "discord_alice_reply_thread:thread-1";let mut history = Vec::new();- history.push(tinyagents_session::transcript::ChatMessage::user(+ history.push(tinychannels_bus::context::ChatMessage::user("short",));history.extend((0..20).map(|idx| {- tinyagents_session::transcript::ChatMessage::assistant("x".repeat(700 + idx))+ tinychannels_bus::context::ChatMessage::assistant("x".repeat(700 + idx))}));ctx.conversation_histories.lock().unwrap().insert(sender.into(), history);- assert!(compact_sender_history(&ctx, sender));+ assert!(compact_sender_history(&ctx.conversation_histories, sender));{let compacted = ctx.conversation_histories.lock().unwrap();let compacted = compacted.get(sender).unwrap();@@ -110,7 +110,7 @@ fn clear_and_compact_sender_history_update_cached_messages() {}));}- clear_sender_history(&ctx, sender);+ clear_sender_history(&ctx.conversation_histories, sender);assert!(!ctx.conversation_histories.lock()diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 70bf0d9ba6..467838aa00 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -17,6 +17,7 @@ use crate::util::truncate_with_ellipsis;use std::sync::Arc;use std::time::{Duration, Instant};use tinyagents_session::transcript::TranscriptMessage;+use tinychannels_bus::context::ChatMessage;use tinychannels_bus as traits;use tokio_util::sync::CancellationToken;use tokio_util::task::AbortOnDropHandle;@@ -252,12 +253,22 @@ pub(crate) async fn process_channel_runtime_message(let started_at = Instant::now();// Build history from per-sender conversation cache- let mut prior_turns = ctx+ let mut prior_turns: Vec<TranscriptMessage> = ctx.conversation_histories.lock().unwrap_or_else(|e| e.into_inner()).get(&history_key)- .cloned()+ .map(|turns| {+ // The cache holds the bus's plain `ChatMessage`; convert at the+ // harness boundary.+ turns+ .iter()+ .map(|turn| match turn.role.as_str() {+ "assistant" => TranscriptMessage::assistant(&turn.content),+ _ => TranscriptMessage::user(&turn.content),+ })+ .collect()+ }).unwrap_or_default();// Re-rendered by `ChannelSystemPrompt` only when the active profile or an@@ -482,8 +493,8 @@ pub(crate) async fn process_channel_runtime_message(.lock().unwrap_or_else(|e| e.into_inner());let turns = histories.entry(history_key).or_default();- turns.push(TranscriptMessage::user(&enriched_message));- turns.push(TranscriptMessage::assistant(&response_text));+ turns.push(ChatMessage::user(&enriched_message));+ turns.push(ChatMessage::assistant(&response_text));// Trim to MAX_CHANNEL_HISTORY (keep recent turns)while turns.len() > crate::channels::context::MAX_CHANNEL_HISTORY {turns.remove(0);diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rsindex d9b74b8eb4..d7ba9efb47 100644--- a/crates/openhuman-core/src/channels/runtime/test_support.rs+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs@@ -21,7 +21,7 @@ use std::path::PathBuf;use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};use std::time::Duration;-use tinyagents_session::transcript::TranscriptMessage;+use tinychannels_bus::context::ChatMessage;use tinychannels_bus::{ChannelMessage, SendMessage};use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};use tinytools::{Tool, ToolResult};@@ -396,7 +396,7 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHaconversation_histories.lock().expect("history lock").insert(history_key.clone(),(0..options.seed_history_len)- .map(|idx| TranscriptMessage::assistant(format!("prior {idx} {}", "x".repeat(700))))+ .map(|idx| ChatMessage::assistant(format!("prior {idx} {}", "x".repeat(700)))).collect(),);}