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(web_chat): route heartbeat spawn through dispatch context
Steven Enamakel55ff18852448
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rsindex fb9bfb1c8e..d2af7993c1 100644--- a/crates/openhuman-core/src/web_chat/turn_host.rs+++ b/crates/openhuman-core/src/web_chat/turn_host.rs@@ -557,8 +557,11 @@ fn tap_progress(}/// The `inference_heartbeat` liveness beat for the turn's projection.-fn spawn_heartbeat(projection: Arc<AsyncMutex<ProgressProjection>>) -> tokio::task::JoinHandle<()> {- tokio::spawn(async move {+fn spawn_heartbeat(+ ctx: &DispatchCtx,+ projection: Arc<AsyncMutex<ProgressProjection>>,+) -> tokio::task::JoinHandle<()> {+ ctx.spawn(async move {let mut beat = tokio::time::interval(Duration::from_secs(INFERENCE_HEARTBEAT_SECS));// Wall-clock cadence: a slow turn must not produce a burst of catch-up// beats once it finally yields control.diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.jsonindex eca6141198..bd6b38e18e 100644--- a/scripts/ci/agent-runtime-boundary-baseline.json+++ b/scripts/ci/agent-runtime-boundary-baseline.json@@ -93,7 +93,7 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/channels/proactive.rs",- "line": 306,+ "line": 228,"text": "let (outcome, request_id) = crate::agent::turn_origin::with_origin(","occurrence": 1},@@ -156,35 +156,35 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/flows/ops/execution.rs",- "line": 312,+ "line": 315,"text": "let run = with_origin(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/flows/ops/resume.rs",- "line": 305,+ "line": 308,"text": "let run = with_origin(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/flows/tinyflows/caps/agent.rs",- "line": 469,+ "line": 467,"text": "Box::pin(turn_origin::with_origin(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/flows/tinyflows/caps/tier.rs",- "line": 118,+ "line": 116,"text": "turn_origin::with_origin(","occurrence": 1},{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs",- "line": 591,+ "line": 592,"text": "let run = crate::agent::turn_origin::with_origin(","occurrence": 1},@@ -310,7 +310,7 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/voice/realtime_harness/agent.rs",- "line": 13,+ "line": 12,"text": "use crate::agent::turn_origin::{with_origin, AgentTurnOrigin};","occurrence": 1},@@ -331,15 +331,22 @@{"rule": "openhuman-task-local","path": "crates/openhuman-core/src/web_chat/ops/system_turn.rs",- "line": 89,+ "line": 88,"text": "let result = with_origin(origin, agent.run_single(prompt))","occurrence": 1},{"rule": "openhuman-task-local",- "path": "crates/openhuman-core/src/web_chat/ops/turn_guards.rs",- "line": 254,- "text": "crate::agent::turn_origin::with_origin(",+ "path": "crates/openhuman-core/src/web_chat/turn_host.rs",+ "line": 40,+ "text": "use crate::agent::turn_origin::{with_origin, AgentTurnOrigin};",+ "occurrence": 1+ },+ {+ "rule": "openhuman-task-local",+ "path": "crates/openhuman-core/src/web_chat/turn_host.rs",+ "line": 268,+ "text": "let turn = Box::pin(with_origin(","occurrence": 1},{@@ -398,6 +405,118 @@"text": "pub struct ToolRegistry<State: Send + Sync, Ctx: Send + Sync> {","occurrence": 1},+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/lib.rs",+ "line": 162,+ "text": "pub use progress::AgentProgress;",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/progress.rs",+ "line": 11,+ "text": "pub enum AgentProgress {",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/progress.rs",+ "line": 468,+ "text": "impl AgentProgress {",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 134,+ "text": "async fn progress(&self, _request: &TurnRequest, _event: crate::progress::AgentProgress) {}",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 560,+ "text": "async fn progress(&self, _request: &TurnRequest, _event: crate::progress::AgentProgress) {}",+ "occurrence": 2+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 579,+ "text": "async fn progress(&self, _request: &TurnRequest, _event: crate::progress::AgentProgress) {}",+ "occurrence": 3+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 987,+ "text": "async fn progress(&self, _request: &TurnRequest, _event: crate::progress::AgentProgress) {}",+ "occurrence": 4+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1215,+ "text": "async fn progress(&self, _request: &TurnRequest, event: crate::progress::AgentProgress) {",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1217,+ "text": "crate::progress::AgentProgress::TurnStarted => \"progress\",",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1255,+ "text": "crate::progress::AgentProgress::TurnStarted,",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1740,+ "text": "async fn progress(&self, _request: &TurnRequest, _event: crate::progress::AgentProgress) {",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1778,+ "text": "crate::progress::AgentProgress::TurnStarted,",+ "occurrence": 2+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/mod_tests.rs",+ "line": 1982,+ "text": "_event: crate::progress::AgentProgress,",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/types.rs",+ "line": 14,+ "text": "use crate::progress::AgentProgress;",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/types.rs",+ "line": 169,+ "text": "Progress(Box<AgentProgress>),",+ "occurrence": 1+ },+ {+ "rule": "tinyagents-openhuman-domain-name",+ "path": "vendor/tinyagents/crates/tinyagents-harness/src/turn_runner/types.rs",+ "line": 229,+ "text": "async fn progress(&self, request: &TurnRequest<P>, event: AgentProgress);",+ "occurrence": 1+ },{"rule": "tinyagents-tool-calling-facade","path": "vendor/tinyagents/crates/tinyagents-harness/src/agent_loop/dialect.rs",@@ -450,7 +569,7 @@{"rule": "tinyagents-tool-calling-facade","path": "vendor/tinyagents/crates/tinyagents-harness/src/lib.rs",- "line": 128,+ "line": 130,"text": "pub use tinytools_agent;","occurrence": 1},diff --git a/scripts/ci/saas-ambient-baseline.json b/scripts/ci/saas-ambient-baseline.jsonindex d1de8717e3..2263b6fbe4 100644--- a/scripts/ci/saas-ambient-baseline.json+++ b/scripts/ci/saas-ambient-baseline.json@@ -23,7 +23,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/agent/hooks.rs",- "line": 343,+ "line": 355,"text": "tokio::spawn(async move {","occurrence": 1},@@ -114,21 +114,21 @@{"rule": "home-dir","path": "crates/openhuman-core/src/channels/host/adapters.rs",- "line": 288,+ "line": 273,"text": ".map(|u| u.home_dir().to_path_buf())","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs",- "line": 196,+ "line": 197,"text": "_acknowledgment_task = Some(AbortOnDropHandle::new(tokio::spawn(async move {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs",- "line": 326,+ "line": 327,"text": "Some(AbortOnDropHandle::new(tokio::spawn(async move {","occurrence": 1},@@ -338,101 +338,87 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 156,+ "line": 159,"text": "tokio::spawn(async move {","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 157,+ "line": 160,"text": "match crate::config::Config::load_or_init().await {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 191,+ "line": 197,"text": "tokio::spawn(async {","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 192,+ "line": 198,"text": "match crate::config::Config::load_or_init().await {","occurrence": 2},{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 222,+ "line": 228,"text": "tokio::spawn(async {","occurrence": 2},{"rule": "ambient-config","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 224,+ "line": 230,"text": "match crate::config::Config::load_or_init().await {","occurrence": 3},{"rule": "ambient-config","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 312,+ "line": 321,"text": "let config = match crate::config::Config::load_or_init().await {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 423,+ "line": 437,"text": "tokio::spawn(async move {","occurrence": 2},{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 480,+ "line": 494,"text": "tokio::spawn(async move {","occurrence": 3},{"rule": "ambient-config","path": "crates/openhuman-core/src/core/runtime/services.rs",- "line": 482,+ "line": 496,"text": "let config = match Config::load_or_init().await {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/core/runtime/subscribers.rs",- "line": 179,+ "line": 189,"text": "tokio::spawn(async move {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/cron/ops.rs",- "line": 227,+ "line": 235,"text": "tokio::spawn(async move {","occurrence": 1},- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs",- "line": 140,- "text": "tokio::spawn(async move {",- "occurrence": 1- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs",- "line": 145,- "text": "let signals = match tokio::task::spawn_blocking(move || signals::sample(&env)).await {",- "occurrence": 1- },{"rule": "bare-spawn","path": "crates/openhuman-core/src/desktop/app_state/ops/runtime_snapshot.rs",@@ -450,14 +436,14 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/flows/ops/builder_gates.rs",- "line": 110,+ "line": 116,"text": "let loaded = tokio::task::spawn_blocking(move || load_flow_graph(&config, &id))","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/flows/ops/run.rs",- "line": 121,+ "line": 125,"text": "tokio::spawn(crate::core::runtime::context::CoreContext::propagate(","occurrence": 1},@@ -485,7 +471,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs",- "line": 577,+ "line": 578,"text": "tokio::spawn(async move { while rx.recv().await.is_some() {} });","occurrence": 1},@@ -555,35 +541,35 @@{"rule": "ambient-config","path": "crates/openhuman-core/src/inference/tokenjuice/mod.rs",- "line": 289,+ "line": 290,"text": "None => match crate::config::Config::load_or_init().await {","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/inference/tokenjuice/mod.rs",- "line": 370,+ "line": 371,"text": "let config = crate::config::Config::load_or_init()","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/inference/tokenjuice/mod.rs",- "line": 383,+ "line": 384,"text": "let config = crate::config::Config::load_or_init()","occurrence": 2},{"rule": "ambient-config","path": "crates/openhuman-core/src/inference/tokenjuice/mod.rs",- "line": 405,+ "line": 406,"text": "let config = crate::config::Config::load_or_init()","occurrence": 3},{"rule": "ambient-config","path": "crates/openhuman-core/src/inference/tokenjuice/mod.rs",- "line": 416,+ "line": 417,"text": "let config = crate::config::Config::load_or_init()","occurrence": 4},@@ -632,14 +618,14 @@{"rule": "ambient-context","path": "crates/openhuman-core/src/mcp/module_client.rs",- "line": 516,+ "line": 520,"text": "let Some(context) = crate::core::runtime::CoreContext::current() else {","occurrence": 1},{"rule": "ambient-context","path": "crates/openhuman-core/src/mcp/module_client.rs",- "line": 519,+ "line": 523,"text": "context.session_agent().is_some()","occurrence": 1},@@ -681,7 +667,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/memory/backfill.rs",- "line": 254,+ "line": 259,"text": "tokio::spawn(async move {","occurrence": 1},@@ -706,6 +692,20 @@"text": "let report = tokio::task::spawn_blocking(move || doctor::run(&config_clone, memory))","occurrence": 1},+ {+ "rule": "bare-spawn",+ "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs",+ "line": 140,+ "text": "tokio::spawn(async move {",+ "occurrence": 1+ },+ {+ "rule": "bare-spawn",+ "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs",+ "line": 145,+ "text": "let signals = match tokio::task::spawn_blocking(move || signals::sample(&env)).await {",+ "occurrence": 1+ },{"rule": "bare-spawn","path": "crates/openhuman-core/src/platform/service/bus.rs",@@ -744,7 +744,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/sandbox/native_jail.rs",- "line": 111,+ "line": 113,"text": "tokio::spawn(async move {","occurrence": 1},@@ -758,28 +758,28 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/security/credentials/ops/gated_services.rs",- "line": 84,+ "line": 87,"text": "tokio::task::spawn_blocking(move || {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/security/credentials/ops/gated_services.rs",- "line": 104,+ "line": 107,"text": "tokio::spawn(async move {","occurrence": 2},{"rule": "bare-spawn","path": "crates/openhuman-core/src/security/credentials/ops/gated_services.rs",- "line": 132,+ "line": 136,"text": "tokio::spawn(async move {","occurrence": 3},{"rule": "bare-spawn","path": "crates/openhuman-core/src/security/credentials/ops/gated_services.rs",- "line": 156,+ "line": 161,"text": "tokio::spawn(async move {","occurrence": 4},@@ -856,28 +856,28 @@{"rule": "ambient-config","path": "crates/openhuman-core/src/skills/runtime/run_machinery.rs",- "line": 64,+ "line": 65,"text": "let config_snapshot = match Config::load_or_init().await {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/skills/runtime/run_machinery.rs",- "line": 160,+ "line": 162,"text": "tokio::spawn(async move {","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/skills/runtime/run_machinery.rs",- "line": 166,+ "line": 168,"text": "let mut config = match Config::load_or_init().await {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/skills/runtime/run_machinery.rs",- "line": 223,+ "line": 222,"text": "let bridge = tokio::spawn(run_log::drain_to_log(rx, log_path.clone()));","occurrence": 1},@@ -933,7 +933,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/threads/ops/edit.rs",- "line": 404,+ "line": 399,"text": "let result = tokio::task::spawn_blocking(move || {","occurrence": 1},@@ -989,14 +989,14 @@{"rule": "ambient-context","path": "crates/openhuman-core/src/tools/ops.rs",- "line": 555,+ "line": 558,"text": "let domains = crate::core::runtime::context::CoreContext::current().map(|c| c.domains());","occurrence": 1},{"rule": "ambient-config","path": "crates/openhuman-core/src/tools/registry/ops.rs",- "line": 43,+ "line": 44,"text": "let config = Config::load_or_init().await.map_err(|err| {","occurrence": 1},@@ -1024,7 +1024,7 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/voice/dictation_listener.rs",- "line": 183,+ "line": 188,"text": "let task = tokio::spawn(async move {","occurrence": 1},@@ -1052,91 +1052,49 @@{"rule": "bare-spawn","path": "crates/openhuman-core/src/voice/server/singleton.rs",- "line": 77,+ "line": 78,"text": "tokio::spawn(async move {","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/voice/server/singleton.rs",- "line": 105,+ "line": 107,"text": "tokio::spawn(async move {","occurrence": 2},{"rule": "env-mutation","path": "crates/openhuman-core/src/web3/wallet/test_support.rs",- "line": 95,+ "line": 94,"text": "std::env::set_var(name, format!(\"http://127.0.0.1:{port}\"));","occurrence": 1},{"rule": "env-mutation","path": "crates/openhuman-core/src/web3/wallet/test_support.rs",- "line": 108,+ "line": 107,"text": "Some(v) => std::env::set_var(name, v),","occurrence": 1},{"rule": "env-mutation","path": "crates/openhuman-core/src/web3/wallet/test_support.rs",- "line": 109,+ "line": 108,"text": "None => std::env::remove_var(name),","occurrence": 1},- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/followups.rs",- "line": 13,- "text": "tokio::spawn(crate::core::runtime::context::CoreContext::propagate(",- "occurrence": 1- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/parallel_turn.rs",- "line": 56,- "text": "let handle = tokio::spawn(crate::core::runtime::context::CoreContext::propagate(",- "occurrence": 1- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/parallel_turn.rs",- "line": 253,- "text": "tokio::spawn(async move {",- "occurrence": 1- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/parallel_turn.rs",- "line": 290,- "text": "tokio::spawn(async move {",- "occurrence": 2- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/start_chat.rs",- "line": 505,- "text": "let handle = tokio::spawn(crate::core::runtime::context::CoreContext::propagate(",- "occurrence": 1- },- {- "rule": "bare-spawn",- "path": "crates/openhuman-core/src/web_chat/ops/state.rs",- "line": 117,- "text": "tokio::spawn(async move {",- "occurrence": 1- },{"rule": "bare-spawn","path": "crates/openhuman-core/src/web_chat/ops/system_turn.rs",- "line": 85,+ "line": 84,"text": "let progress_drain = tokio::spawn(async move { while progress_rx.recv().await.is_some() {} });","occurrence": 1},{"rule": "bare-spawn","path": "crates/openhuman-core/src/web_chat/presentation.rs",- "line": 111,+ "line": 123,"text": "let persisted = tokio::task::spawn_blocking(move || {","occurrence": 1},