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): extract durable session reset into its own module
Steven Enamakel2bbdfc38860e
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rsindex 4ab4b9ac7d..6c64addfa8 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs@@ -17,6 +17,7 @@mod approval;mod bus_turn;mod progressive;+mod reset;mod turn;use crate::channels::context::ChannelRuntimeContext;@@ -78,6 +79,7 @@ impl From<ChannelMessage> for RuntimeChannelMessage {#[cfg(test)]pub(crate) use approval::channel_has_approval_surface;+pub(crate) use reset::reset_durable_channel_session;pub(crate) use turn::{process_channel_message, process_channel_runtime_message};/// Run every inbound message through the agent pipeline, at mostdiff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rsnew file mode 100644index 0000000000..a15bbea282--- /dev/null+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/reset.rs@@ -0,0 +1,42 @@+use super::super::host_agent::{self, HostRoute};+use crate::channels::context::ChannelRuntimeContext;++/// Reset the durable session selected for this channel conversation. The+/// module still owns command parsing; this host adapter resolves trusted agent+/// authority and serializes the generation transition with turns.+pub(crate) async fn reset_durable_channel_session(+ ctx: &ChannelRuntimeContext,+ msg: &tinychannels_bus::ChannelMessage,+ session_key: &str,+ history_key: &str,+) -> anyhow::Result<bool> {+ let host = match host_agent::route(ctx, &msg.channel) {+ HostRoute::Agent(host) => *host,+ HostRoute::Missing(agent_id) => {+ anyhow::bail!("configured channel agent {agent_id} is unavailable")+ }+ HostRoute::Unbound => host_agent::configured_agent(+ ctx,+ &crate::channels::routes::get_route_selection(ctx, history_key),+ )+ .await+ .map_err(anyhow::Error::msg)?,+ };+ let dispatch = ctx.dispatch_ctx();+ let tenant = dispatch.tenant().map_err(anyhow::Error::msg)?;+ let lease = crate::agent::session_lease::SessionLease::acquire(+ crate::agent::session_lease::SessionLeaseKey::new(+ crate::core::runtime::tenant::tenant_key(&tenant, ""),+ host.definition.id.clone(),+ session_key.to_owned(),+ ),+ None,+ )+ .await+ .map_err(|()| anyhow::anyhow!("channel session reset was cancelled"))?;+ let reset = host+ .reset_external_channel_history(session_key, history_key, &msg.channel)+ .await;+ drop(lease);+ reset+}diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 6aca327a14..37168f8f2c 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -25,6 +25,7 @@ use super::super::host_agent::{self, HostRoute};use super::approval::{channel_has_approval_surface, try_route_approval_reply};#[cfg(test)]use super::bus_turn::dispatch_bus_turn;+use super::reset_durable_channel_session;use super::RuntimeChannelMessage;pub(crate) async fn process_channel_message(@@ -747,39 +748,3 @@ pub(crate) async fn process_channel_runtime_message(workspace_dir: ctx.workspace_dir.as_ref().clone(),});}--async fn reset_durable_channel_session(- ctx: &ChannelRuntimeContext,- msg: &traits::ChannelMessage,- session_key: &str,- history_key: &str,-) -> anyhow::Result<bool> {- let host = match host_agent::route(ctx, &msg.channel) {- HostRoute::Agent(host) => *host,- HostRoute::Missing(agent_id) => {- anyhow::bail!("configured channel agent {agent_id} is unavailable")- }- HostRoute::Unbound => {- host_agent::configured_agent(ctx, &get_route_selection(ctx, history_key))- .await- .map_err(anyhow::Error::msg)?- }- };- let dispatch = ctx.dispatch_ctx();- let tenant = dispatch.tenant().map_err(anyhow::Error::msg)?;- let lease = crate::agent::session_lease::SessionLease::acquire(- crate::agent::session_lease::SessionLeaseKey::new(- crate::core::runtime::tenant::tenant_key(&tenant, ""),- host.definition.id.clone(),- session_key.to_owned(),- ),- None,- )- .await- .map_err(|()| anyhow::anyhow!("channel session reset was cancelled"))?;- let reset = host- .reset_external_channel_history(session_key, history_key, &msg.channel)- .await;- drop(lease);- reset-}