Skip to content

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

refactor(channels): remove conversation history management from context

Steven Enamakel55c5684e891b
diff --git a/crates/openhuman-core/src/channels/context.rs b/crates/openhuman-core/src/channels/context.rs
index 3c4273889f..263cc41ee9 100644
--- a/crates/openhuman-core/src/channels/context.rs
+++ b/crates/openhuman-core/src/channels/context.rs
@@ -15,17 +15,6 @@ pub(crate) use tinychannels_runtime::context::{
DEFAULT_CHANNEL_INITIAL_BACKOFF_SECS, DEFAULT_CHANNEL_MAX_BACKOFF_SECS, MAX_CHANNEL_HISTORY,
};
-#[cfg(test)]
-pub(crate) use tinychannels_runtime::context::{clear_sender_history, ConversationHistoryMap};
-
-#[cfg(test)]
-pub(crate) use tinychannels_runtime::context::compact_sender_history;
-
-#[cfg(test)]
-pub(crate) use tinychannels_runtime::context::{
- CHANNEL_HISTORY_COMPACT_CONTENT_CHARS, CHANNEL_HISTORY_COMPACT_KEEP_MESSAGES,
-};
-
#[cfg(test)]
pub(crate) use tinychannels::context::{
effective_channel_message_timeout_secs, MIN_CHANNEL_MESSAGE_TIMEOUT_SECS,
@@ -55,8 +44,6 @@ pub(crate) struct ChannelRuntimeContext {
pub(crate) model: Arc<String>,
pub(crate) temperature: f64,
pub(crate) max_tool_iterations: usize,
- #[cfg(test)]
- pub(crate) conversation_histories: ConversationHistoryMap,
pub(crate) turn_model_source_cache: TurnModelSourceCacheMap,
pub(crate) route_overrides: RouteSelectionMap,
pub(crate) api_url: Option<String>,
diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rs
index ef7ad52ffb..efc293cb22 100644
--- a/crates/openhuman-core/src/channels/context_tests.rs
+++ b/crates/openhuman-core/src/channels/context_tests.rs
@@ -87,40 +87,6 @@ fn timeout_and_history_keys_respect_channel_rules() {
);
}
-#[test]
-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(tinychannels_runtime::context::ChatMessage::user("short"));
- history.extend(
- (0..20).map(|idx| {
- tinychannels_runtime::context::ChatMessage::assistant("x".repeat(700 + idx))
- }),
- );
- ctx.conversation_histories
- .lock()
- .unwrap()
- .insert(sender.into(), history);
-
- assert!(compact_sender_history(&ctx.conversation_histories, sender));
- {
- let compacted = ctx.conversation_histories.lock().unwrap();
- let compacted = compacted.get(sender).unwrap();
- assert_eq!(compacted.len(), CHANNEL_HISTORY_COMPACT_KEEP_MESSAGES);
- assert!(compacted.iter().all(|msg| {
- msg.content.chars().count() <= CHANNEL_HISTORY_COMPACT_CONTENT_CHARS + 3
- }));
- }
-
- clear_sender_history(&ctx.conversation_histories, sender);
- assert!(!ctx
- .conversation_histories
- .lock()
- .unwrap()
- .contains_key(sender));
-}
-
#[tokio::test]
async fn overflow_detection_covers_edge_cases() {
let ctx = runtime_context();
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index b65cb2a574..cf7318e479 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -1,8 +1,6 @@
//! Per-sender routing and runtime command handling.
#[cfg(test)]
-#[cfg(test)]
-use super::context::clear_sender_history;
use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
use super::{Channel, ChannelSendExt, SendMessage};
use crate::inference::provider;
@@ -348,10 +346,7 @@ pub(crate) async fn handle_runtime_command_if_needed(
None,
None,
msg,
- || async {
- clear_sender_history(&ctx.conversation_histories, sender_key);
- Ok(())
- },
+ || async { Ok(()) },
)
.await
}