Skip to content

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

chore(channels): tidy imports and formatting in host agent dispatch

Steven Enamakel5d4b136ea008
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index 3081a6ab20..aa7369d725 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -95,7 +95,9 @@ impl HostAgent {
approval: crate::security::approval::ApprovalTurnContext,
progress: Option<tokio::sync::mpsc::Sender<tinyagents_harness::progress::AgentProgress>>,
run_queue: Option<
- std::sync::Arc<tinyagents_harness::run_queue::RunQueue<crate::agent::queued_turn::QueuedTurn>>,
+ std::sync::Arc<
+ tinyagents_harness::run_queue::RunQueue<crate::agent::queued_turn::QueuedTurn>,
+ >,
>,
cancellation: tinyagents_harness::CancellationToken,
turn_deadline: Option<std::time::Duration>,
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index 26f13962a6..1c8ec97ca5 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -1,8 +1,8 @@
//! Per-sender routing and runtime command handling.
-use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
#[cfg(test)]
use super::context::clear_sender_history;
+use super::context::{ChannelRouteSelection, ChannelRuntimeContext};
use super::{Channel, ChannelSendExt, SendMessage};
use crate::inference::provider;
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index 61043da489..553cb3ed27 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -395,6 +395,54 @@ async fn handle_runtime_command_set_model_clears_sender_history_and_persists_rou
assert!(sent[0].content.contains("Model switched to `gpt-5-mini`"));
}
+#[tokio::test]
+async fn clear_history_command_uses_durable_reset_callback_without_clearing_ram_history() {
+ let ctx = runtime_context(PathBuf::from("/tmp"));
+ let key = "telegram_alice_room";
+ ctx.conversation_histories
+ .lock()
+ .unwrap()
+ .insert(key.to_string(), vec![ChatMessage::user("old history")]);
+ let channel_impl = Arc::new(RecordingChannel::default());
+ let channel: Arc<dyn Channel> = channel_impl.clone();
+ let msg = ChannelMessage {
+ reply_to_id: None,
+ topic_id: None,
+ id: "reset-1".into(),
+ sender: "alice".into(),
+ reply_target: "room".into(),
+ content: "/model gpt-5-mini".into(),
+ channel: "telegram".into(),
+ timestamp: 0,
+ thread_ts: None,
+ sender_name: None,
+ };
+ let reset_called = Arc::new(std::sync::atomic::AtomicBool::new(false));
+ let reset_called_by_callback = Arc::clone(&reset_called);
+
+ let handled = handle_runtime_command_with_reset(
+ &ctx,
+ &msg,
+ Some(&channel),
+ &conversation_history_key(&msg),
+ move || async move {
+ reset_called_by_callback.store(true, std::sync::atomic::Ordering::SeqCst);
+ Ok(())
+ },
+ )
+ .await;
+
+ assert!(handled);
+ assert!(reset_called.load(std::sync::atomic::Ordering::SeqCst));
+ assert!(ctx.conversation_histories.lock().unwrap().contains_key(key));
+ assert_eq!(
+ get_route_selection(&ctx, key).model,
+ "gpt-5-mini",
+ "route changes are applied before the durable reset callback runs"
+ );
+ assert_eq!(channel_impl.sent.lock().unwrap().len(), 1);
+}
+
#[tokio::test]
async fn handle_runtime_command_telegram_status_replies_without_agent() {
let ctx = runtime_context(PathBuf::from("/tmp"));
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
index 7752270c77..98befa4607 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
@@ -29,7 +29,7 @@ use tinychannels_bus as traits;
pub(crate) mod posture;
mod turn;
-pub(crate) use turn::{HostChannelTurn, run_host_agent_turn};
+pub(crate) use turn::{run_host_agent_turn, HostChannelTurn};
/// Resolve the config-owned target selected for an unbound channel into the
/// same trusted host-agent carrier used by channel bindings. The effective
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs
index f8042ab4f7..13a23a473e 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/turn.rs
@@ -1,7 +1,7 @@
//! Running one channel turn as a host agent.
-use tokio::sync::mpsc;
use tinyagents_harness::run_queue::RunQueue;
+use tokio::sync::mpsc;
use super::posture;
use crate::agent::bus::AgentTurnResponse;
@@ -27,9 +27,7 @@ pub(crate) struct HostChannelTurn {
pub(crate) origin: AgentTurnOrigin,
/// Live progress for the channel's draft updates.
pub(crate) progress: Option<mpsc::Sender<AgentProgress>>,
- pub(crate) run_queue: Option<
- std::sync::Arc<RunQueue<crate::agent::queued_turn::QueuedTurn>>,
- >,
+ pub(crate) run_queue: Option<std::sync::Arc<RunQueue<crate::agent::queued_turn::QueuedTurn>>>,
/// Where this turn's parked approvals surface; default for a channel
/// without an approval surface.
pub(crate) approval: crate::security::approval::ApprovalTurnContext,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 3eed18d761..6aca327a14 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -522,13 +522,11 @@ pub(crate) async fn process_channel_runtime_message(
}
}
#[cfg(not(test))]
- None => {
- super::native_runner::NativeTurnExecution {
- result: Err("channel turn has no configured host agent".to_owned()),
- delivery_succeeded: None,
- queued: false,
- }
- }
+ None => super::native_runner::NativeTurnExecution {
+ result: Err("channel turn has no configured host agent".to_owned()),
+ delivery_succeeded: None,
+ queued: false,
+ },
};
if execution.queued {
return;