Skip to content

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

test(channels): update runtime command tests for history key argument

Steven Enamakele43483ca0839
diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rs
index 4273a97214..aa5fd547b7 100644
--- a/crates/openhuman-core/src/channels/context_tests.rs
+++ b/crates/openhuman-core/src/channels/context_tests.rs
@@ -117,8 +117,9 @@ fn clear_and_compact_sender_history_update_cached_messages() {
.contains_key(sender));
}
-#[test]
-fn overflow_detection_covers_edge_cases() {
+#[tokio::test]
+async fn overflow_detection_covers_edge_cases() {
+ let ctx = runtime_context();
assert!(is_context_window_overflow_error(&anyhow::anyhow!(
"Maximum context length exceeded"
)));
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index ee158ecc0d..aba28fddbf 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::channels::context::{ChannelRuntimeContext, RouteSelectionMap, TurnModelSourceCacheMap};
+use crate::channels::context::{conversation_history_key, ChannelRuntimeContext, RouteSelectionMap, TurnModelSourceCacheMap};
use crate::channels::host::ChannelTurnStateSubscriber;
use crate::channels::traits::ChannelMessage;
use crate::core::events::DomainEvent;
@@ -256,7 +256,7 @@ async fn handle_runtime_command_unknown_provider_sends_helpful_error() {
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel)).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel), &conversation_history_key(&msg)).await;
assert!(handled);
let sent = channel_impl.sent.lock().unwrap();
@@ -288,7 +288,7 @@ async fn handle_runtime_command_set_model_clears_sender_history_and_persists_rou
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel)).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel), &conversation_history_key(&msg)).await;
assert!(handled);
assert!(ctx
@@ -326,7 +326,7 @@ async fn handle_runtime_command_telegram_status_replies_without_agent() {
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel)).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel), &conversation_history_key(&msg)).await;
assert!(handled);
let sent = channel_impl.sent.lock().unwrap();
@@ -349,7 +349,7 @@ async fn handle_runtime_command_without_target_channel_still_consumes_command()
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, None).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, None, &conversation_history_key(&msg)).await;
assert!(handled);
}
@@ -369,7 +369,7 @@ async fn handle_runtime_command_telegram_help_replies_with_remote_command_list()
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel)).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel), &conversation_history_key(&msg)).await;
assert!(handled);
let sent = channel_impl.sent.lock().unwrap();
@@ -400,7 +400,7 @@ async fn handle_runtime_command_telegram_sessions_reports_empty_store() {
sender_name: None,
};
- let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel)).await;
+ let handled = handle_runtime_command_if_needed(&ctx, &msg, Some(&channel), &conversation_history_key(&msg)).await;
assert!(handled);
let sent = channel_impl.sent.lock().unwrap();
@@ -434,7 +434,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
thread_ts: Some("42".into()),
sender_name: None,
};
- assert!(handle_runtime_command_if_needed(&ctx, &new_msg, Some(&channel)).await);
+ assert!(handle_runtime_command_if_needed(&ctx, &new_msg, Some(&channel), &conversation_history_key(&new_msg)).await);
assert!(ctx
.conversation_histories
.lock()
@@ -479,7 +479,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
thread_ts: Some("42".into()),
sender_name: None,
};
- assert!(handle_runtime_command_if_needed(&ctx, &status_msg, Some(&channel)).await);
+ assert!(handle_runtime_command_if_needed(&ctx, &status_msg, Some(&channel), &conversation_history_key(&status_msg)).await);
let sessions_msg = ChannelMessage {
id: "4".into(),
@@ -491,7 +491,7 @@ async fn handle_runtime_command_telegram_new_status_and_sessions_round_trip() {
thread_ts: Some("42".into()),
sender_name: None,
};
- assert!(handle_runtime_command_if_needed(&ctx, &sessions_msg, Some(&channel)).await);
+ assert!(handle_runtime_command_if_needed(&ctx, &sessions_msg, Some(&channel), &conversation_history_key(&sessions_msg)).await);
let sent = channel_impl.sent.lock().unwrap();
assert_eq!(sent.len(), 3);
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
index ac035a582a..82c6c348ab 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -226,7 +226,7 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->
// Remote-control turn state (`/status` shows "in progress") for every
// channel with the `remote_control` capability.
let _turn_state_handle = bus.subscribe(Arc::new(
- crate::channels::host::ChannelTurnStateSubscriber::new(config.workspace_dir.clone()),
+ crate::channels::host::ChannelTurnStateSubscriber::with_config(Arc::new(config.clone())),
));
// In-chat approvals (sub-issue 2 of #3098) for every channel with the
// `chat_approvals` capability: `Prompt`-class tool calls are gated for the
@@ -234,7 +234,10 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->
// each such turn in an `ApprovalChatContext` and intercepting `yes`/`no`
// replies for parked approvals.
let _approval_surface_handle = bus.subscribe(Arc::new(
- crate::channels::host::ChannelApprovalSurfaceSubscriber::new(Arc::clone(&channels_by_name)),
+ crate::channels::host::ChannelApprovalSurfaceSubscriber::with_config(
+ Arc::clone(&channels_by_name),
+ Arc::new(config.clone()),
+ ),
));
tracing::debug!("[channels] registered turn-state and approval-surface subscribers");