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
feat(channels): add per-turn timeout handling to dispatch
Steven Enamakelf62d4d64588e
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rsindex 1ded4ba5f5..1a7ea54d2c 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs@@ -16,7 +16,7 @@ pub(super) fn log_worker_join_result(result: Result<(), tokio::task::JoinError>)}/// Start the portable typing lifecycle with OpenHuman's configured interval.-pub(super) fn spawn_scoped_typing_task(+pub(super) fn spawn_typing_task(channel: std::sync::Arc<dyn crate::channels::Channel>,recipient: String,cancellation_token: tokio_util::sync::CancellationToken,diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rsindex 2b25366c1f..008c2b6504 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs@@ -44,7 +44,7 @@ async fn canceled_waiter_closes_handle_returned_by_in_flight_typing_start() {});let cancellation = tokio_util::sync::CancellationToken::new();let waiter =- spawn_scoped_typing_task(channel.clone(), "recipient".into(), cancellation.clone());+ spawn_typing_task(channel.clone(), "recipient".into(), cancellation.clone());channel.started.notified().await;waiter.abort();cancellation.cancel();diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 16fe49d7cf..9ec2da5ae9 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -23,7 +23,7 @@ use tokio_util::sync::CancellationToken;use tokio_util::task::AbortOnDropHandle;use super::super::helpers::{- build_channel_context_block, log_worker_join_result, spawn_scoped_typing_task,+ build_channel_context_block, log_worker_join_result, spawn_typing_task,REPLY_LOG_TRUNCATE_CHARS,};use super::super::host_agent::{self, run_host_agent_turn, seed_rows, HostChannelTurn, HostRoute};@@ -387,7 +387,7 @@ pub(crate) async fn process_channel_runtime_message(// Typing was already started early (before memory/provider setup). Here we only// spawn the background refresh task that keeps the indicator alive during long turns.let typing_task = match (target_channel.as_ref(), typing_cancellation.as_ref()) {- (Some(channel), Some(token)) => Some(AbortOnDropHandle::new(spawn_scoped_typing_task(+ (Some(channel), Some(token)) => Some(AbortOnDropHandle::new(spawn_typing_task(Arc::clone(channel),msg.reply_target.clone(),token.clone(),diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rsindex 30e1da1f5e..7f858c9cb1 100644--- a/crates/openhuman-core/src/core/runtime/context.rs+++ b/crates/openhuman-core/src/core/runtime/context.rs@@ -566,7 +566,7 @@ impl CoreContext {////// In SaaS only the caller's own task scope is carried (never the/// operator's default context), together with its memory identity — the- /// same rule as [`spawn_scoped`](crate::core::runtime::spawn_scoped).+ /// same rule as [`DispatchCtx::spawn`](crate::core::runtime::DispatchCtx::spawn).pub fn propagate<F: Future>(fut: F) -> impl Future<Output = F::Output> {super::spawn::carry(fut)}diff --git a/crates/openhuman-core/src/storage/import_claim.rs b/crates/openhuman-core/src/storage/import_claim.rsindex c86983f819..a99e89f633 100644--- a/crates/openhuman-core/src/storage/import_claim.rs+++ b/crates/openhuman-core/src/storage/import_claim.rs@@ -99,7 +99,7 @@ pub fn with_claim_at<T>(// A bare OS thread on purpose (baselined in the SaaS ambient ratchet):// the heartbeat reads no ambient state, only the `repo` handed to it,// and is joined below before this returns. `with_claim` is synchronous- // and may run outside a tokio runtime, so `spawn_blocking_scoped`+ // and may run outside a tokio runtime, so `DispatchCtx::spawn_blocking`// (which needs `Handle::current()`) is not available here.std::thread::spawn(move || {let started = std::time::Instant::now();diff --git a/crates/openhuman-core/src/tools/timeout/mod.rs b/crates/openhuman-core/src/tools/timeout/mod.rsindex 630f785a32..2c9d2b7c06 100644--- a/crates/openhuman-core/src/tools/timeout/mod.rs+++ b/crates/openhuman-core/src/tools/timeout/mod.rs@@ -35,7 +35,7 @@ fn ensure_configured() {CONFIGURE.call_once(|| {let secs = module::resolve_effective(module::DEFAULT_TIMEOUT_SECS, read_env().as_deref());module::configure(module::TimeoutSettings::with_inherited_secs(secs));- module::set_task_wrapper(|fut| Box::pin(crate::core::runtime::spawn::scoped(fut)));+ module::set_task_wrapper(|fut| Box::pin(crate::core::runtime::DispatchCtx::ambient().enter(fut)));log::debug!("[tool_timeout] configured module settings inherited={secs}s");});}