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): own session cancellation in the host
Steven Enamakel4a965e3d4497
diff --git a/crates/openhuman-core/src/channels/controllers/schemas.rs b/crates/openhuman-core/src/channels/controllers/schemas.rsindex f0bd28bc07..6660fa6327 100644--- a/crates/openhuman-core/src/channels/controllers/schemas.rs+++ b/crates/openhuman-core/src/channels/controllers/schemas.rs@@ -222,7 +222,10 @@ pub fn schemas(function: &str) -> ControllerSchema {fn handle_list(_params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {- to_json(Outcome::new(super::definitions::all_channel_definitions(), vec![]))+ to_json(Outcome::new(+ super::definitions::all_channel_definitions(),+ vec![],+ ))})}diff --git a/crates/openhuman-core/src/channels/runtime/session.rs b/crates/openhuman-core/src/channels/runtime/session.rsindex 361f563d63..6485839371 100644--- a/crates/openhuman-core/src/channels/runtime/session.rs+++ b/crates/openhuman-core/src/channels/runtime/session.rs@@ -1,21 +1,35 @@-//! Explicit logout invalidates channel runtimes, independently of model auth.-//!-//! The session mechanics live in `tinychannels::runtime`; this module owns the-//! process's single session.-use std::sync::LazyLock;-use tinychannels::runtime::ChannelSession;+//! Host-owned logout generation and cancellation for channel orchestration.+use std::future::Future;+use std::sync::{LazyLock, Mutex};use tokio_util::sync::CancellationToken;-pub(super) use tinychannels::runtime::run_in_session;--static SESSION: LazyLock<ChannelSession> = LazyLock::new(ChannelSession::new);+static SESSION: LazyLock<Mutex<CancellationToken>> =+ LazyLock::new(|| Mutex::new(CancellationToken::new()));pub(crate) fn channel_session() -> CancellationToken {- SESSION.current()+ SESSION+ .lock()+ .unwrap_or_else(|error| error.into_inner())+ .clone()}pub(crate) fn invalidate_channel_session() {- SESSION.invalidate();+ let mut current = SESSION.lock().unwrap_or_else(|error| error.into_inner());+ current.cancel();+ *current = CancellationToken::new();+}++/// Stop the host dispatch generation on logout, even with independent model auth.+/// Module resource owners explicitly drain their handles when dispatch ends.+pub(super) async fn run_in_session(+ session: CancellationToken,+ runtime: impl Future<Output = anyhow::Result<()>>,+) -> anyhow::Result<()> {+ tokio::select! {+ biased;+ _ = session.cancelled() => Ok(()),+ result = runtime => result,+ }}#[cfg(test)]diff --git a/crates/openhuman-core/src/web_chat/presentation.rs b/crates/openhuman-core/src/web_chat/presentation.rsindex a24a1e8d67..ebb03f5f83 100644--- a/crates/openhuman-core/src/web_chat/presentation.rs+++ b/crates/openhuman-core/src/web_chat/presentation.rs@@ -58,7 +58,14 @@ pub(crate) async fn deliver_response(timing: Option<super::turn_timing::TurnTimingSnapshot>,suggest_follow_ups: bool,) {- persist_reply(thread_id, request_id, full_response, citations, workspace_dir).await;+ persist_reply(+ thread_id,+ request_id,+ full_response,+ citations,+ workspace_dir,+ )+ .await;announce_reply(client_id,thread_id,