Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(core): route background tasks through dispatch context

Steven Enamakel8af8e707e3b8
diff --git a/app/scripts/e2e-run-all-flows.sh b/app/scripts/e2e-run-all-flows.sh
index 249252581d..9c3eabbfc8 100755
--- a/app/scripts/e2e-run-all-flows.sh
+++ b/app/scripts/e2e-run-all-flows.sh
@@ -251,6 +251,7 @@ if should_run_suite "chat"; then
run "test/e2e/specs/chat-harness-subagent-continue.spec.ts" "chat-subagent-continue" "chat"
run "test/e2e/specs/chat-background-activity-panel.spec.ts" "chat-background-activity" "chat"
run "test/e2e/specs/chat-todos-goals.spec.ts" "chat-todos-goals" "chat"
+ run "test/e2e/specs/agent-teams-live.spec.ts" "agent-teams-live" "chat"
run "test/e2e/specs/agent-harness-behaviors.spec.ts" "agent-harness-behaviors" "chat"
run "test/e2e/specs/file-drop-guard.spec.ts" "file-drop-guard" "chat"
run "test/e2e/specs/chat-external-link.spec.ts" "chat-external-link" "chat"
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch_helpers.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch_helpers.rs
index 712afbbab3..f7745c5532 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch_helpers.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch_helpers.rs
@@ -20,7 +20,7 @@ pub(super) fn spawn_subagent_trace_export(
let thread_id = thread_id.map(str::to_owned);
let agent_id = agent_id.to_owned();
let task_id = task_id.to_owned();
- tokio::spawn(async move {
+ dispatch.spawn(async move {
crate::core::observability::progress_tracing::export_subagent_journal_trace(
&dispatch,
&config,
diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rs
index 82e5c8c843..bd85dc6d99 100644
--- a/crates/openhuman-core/src/core/cli.rs
+++ b/crates/openhuman-core/src/core/cli.rs
@@ -482,7 +482,7 @@ fn run_call_command(args: &[String]) -> Result<()> {
let headless_agent_chat = crate::core::legacy_aliases::resolve_legacy(&method)
== crate::agent_runs::INFERENCE_AGENT_CHAT;
let dispatch = if headless_agent_chat {
- let config = crate::config::Config::load_or_init()
+ let config = crate::config::load_config_with_timeout()
.await
.map_err(|error| error.to_string())?;
if crate::agent_registry::host_definition::AgentDefinitionRegistry::global()
diff --git a/crates/openhuman-core/src/inference/auth_error_registry.rs b/crates/openhuman-core/src/inference/auth_error_registry.rs
index 78dc77b568..1502a39c28 100644
--- a/crates/openhuman-core/src/inference/auth_error_registry.rs
+++ b/crates/openhuman-core/src/inference/auth_error_registry.rs
@@ -183,7 +183,9 @@ fn origins() -> &'static Mutex<HashMap<String, ErrorOrigins>> {
}
fn current_scope() -> CurrentScope {
- let Some(context) = crate::core::runtime::CoreContext::current() else {
+ let Some(context) = crate::core::runtime::tenant::context_in(
+ crate::core::runtime::is_saas(),
+ ) else {
return CurrentScope::Unbound;
};
match context.workspace_config_binding() {
diff --git a/crates/openhuman-core/src/threads/ops/purge.rs b/crates/openhuman-core/src/threads/ops/purge.rs
index e81115aa12..0f2440bd8b 100644
--- a/crates/openhuman-core/src/threads/ops/purge.rs
+++ b/crates/openhuman-core/src/threads/ops/purge.rs
@@ -37,7 +37,7 @@ where
Fut: std::future::Future<Output = ()> + Send,
{
let admission_workspace = dir.clone();
- let _admission = tokio::task::spawn_blocking(move || {
+ let _admission = ctx.spawn_blocking(move || {
crate::threads::store::backend::begin_thread_purge(&admission_workspace)
})
.await