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): use durable session key for remote resets
Steven Enamakelb276f63e3cdb
diff --git a/crates/openhuman-core/src/channels/host/remote_control.rs b/crates/openhuman-core/src/channels/host/remote_control.rsindex 7faa519a4a..3d3bffcce6 100644--- a/crates/openhuman-core/src/channels/host/remote_control.rs+++ b/crates/openhuman-core/src/channels/host/remote_control.rs@@ -1,12 +1,16 @@//! Captured host conversation and session state supplied to the channel module.use crate::channels::context::ChannelRuntimeContext;+use crate::channels::Channel;use crate::core::runtime::DispatchCtx;use crate::threads::store::{self as conversations, CreateConversationThread};-use crate::channels::Channel;pub(crate) struct RemoteResetContext {pub(crate) scope: tinychannels_bus::module_remote::RemoteSessionScope,+ /// Host-derived tenant-scoped identity used by TinyAgents. This is kept+ /// separate from the module's opaque route key so remote commands cannot+ /// choose or broaden session identity.+ pub(crate) durable_session_key: String,pub(crate) message: tinychannels_bus::ChannelMessage,pub(crate) history_key: String,}@@ -86,12 +90,9 @@ pub(crate) async fn dispatch_callback(.account_id.as_deref().ok_or_else(|| tinybus::Error::failed("remote reset account is unavailable"))?;- let configured = ctx- .channels_by_name- .get(account)- .is_some_and(|channel| {- tinychannels_bus::provider_id(channel.name()) == session_scope.channel.id- });+ let configured = ctx.channels_by_name.get(account).is_some_and(|channel| {+ tinychannels_bus::provider_id(channel.name()) == session_scope.channel.id+ });if !configured {return Err(tinybus::Error::failed("remote reset account is not configured",@@ -100,7 +101,7 @@ pub(crate) async fn dispatch_callback(crate::channels::runtime::dispatch::reset_durable_channel_session(ctx,&reset.message,- &reset.scope.session_key,+ &reset.durable_session_key,&reset.history_key,).awaitdiff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rsindex f27694fafd..a491902d06 100644--- a/crates/openhuman-core/src/channels/routes.rs+++ b/crates/openhuman-core/src/channels/routes.rs@@ -155,6 +155,7 @@ pub(crate) async fn handle_runtime_command_with_reset<F, Fut>(target_channel: Option<&Arc<dyn Channel>>,sender_key: &str,reset_scope: Option<tinychannels_bus::module_remote::RemoteSessionScope>,+ durable_session_key: Option<String>,reset_message: &traits::ChannelMessage,reset_history: F,) -> bool@@ -182,13 +183,17 @@ whereRouteCallbacks::new(ctx.clone(),super::runtime::session::channel_session(),- reset_scope.clone().map(|scope| {- crate::channels::host::remote_control::RemoteResetContext {- scope,- message: reset_message.clone(),- history_key: sender_key.to_owned(),- }- }),+ reset_scope+ .clone()+ .zip(durable_session_key)+ .map(|(scope, durable_session_key)| {+ crate::channels::host::remote_control::RemoteResetContext {+ scope,+ durable_session_key,+ message: reset_message.clone(),+ history_key: sender_key.to_owned(),+ }+ }),),).await?;@@ -204,7 +209,7 @@ wheremodel: current.model,},history_len,- session_scope: reset_scope,+ session_scope: reset_scope.map(Box::new),providers: provider_descriptors(),},),)@@ -288,10 +293,19 @@ pub(crate) async fn handle_runtime_command_if_needed(target_channel: Option<&Arc<dyn Channel>>,sender_key: &str,) -> bool {- handle_runtime_command_with_reset(ctx, msg, target_channel, sender_key, None, msg, || async {- clear_sender_history(&ctx.conversation_histories, sender_key);- Ok(())- })+ handle_runtime_command_with_reset(+ ctx,+ msg,+ target_channel,+ sender_key,+ None,+ None,+ msg,+ || async {+ clear_sender_history(&ctx.conversation_histories, sender_key);+ Ok(())+ },+ ).await}diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rsindex 8df41e2d57..9c7010e4df 100644--- a/crates/openhuman-core/src/channels/routes_tests.rs+++ b/crates/openhuman-core/src/channels/routes_tests.rs@@ -393,6 +393,7 @@ async fn clear_history_command_uses_reset_callback_and_persists_route_override()Some(&channel),&conversation_history_key(&msg),None,+ None,&msg,move || async move {callback_flag.store(true, std::sync::atomic::Ordering::SeqCst);@@ -436,7 +437,10 @@ async fn remote_clear_without_captured_scope_fails_closed() {).await;- assert!(result.is_err(), "an unscoped reset must never report success");+ assert!(+ result.is_err(),+ "an unscoped reset must never report success"+ );}#[cfg(feature = "modules")]@@ -448,6 +452,7 @@ async fn remote_clear_rejects_an_unconfigured_captured_account() {let scope = remote_session_scope();let reset_context = crate::channels::host::remote_control::RemoteResetContext {scope: scope.clone(),+ durable_session_key: "tenant:session:telegram:bot-a:group:room-1".into(),message: ChannelMessage {channel: "telegram:bot-a".into(),reply_target: "room-1".into(),diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 2f3a6bf12b..816beb7502 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -142,6 +142,7 @@ pub(crate) async fn process_channel_runtime_message(target_channel.as_ref(),&history_key,Some(remote_reset_scope),+ Some(session_key.clone()),&msg,|| async move {reset_durable_channel_session(