Skip to content

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

fix(host_runtime): correct runtime builder to properly initialize inference context

Steven Enamakel60fc4cb13b9f
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index 701499ef1e..185c78e299 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -781,28 +781,12 @@ impl CoreRuntime {
/// jobs, and releasing them is a write to the store, so it has to happen
/// while the store is still open and before anything else on the way out
/// (tinymemory#133). Bounded inside, on one shared deadline: a wedged
- /// store costs at most that budget, never the exit. Then any `ollama
- /// serve` openhuman itself spawned is stopped (no-op when externally
- /// managed), bounded so a wedged Ollama can't hold up shutdown.
+ /// store costs at most that budget, never the exit. There is no local
+ /// model runtime to stop: the user runs Ollama / LM Studio / MLX
+ /// themselves and OpenHuman never spawns it.
pub async fn exit_cleanup(&self) {
crate::memory::exit::shutdown_for_exit().await;
-
- if let Some(svc) = crate::inference::host_runtime::try_global() {
- let cfg = crate::config::Config::load_or_init()
- .await
- .unwrap_or_default();
- let runtime = crate::inference::local_runtime_config(&cfg);
- log::info!("[core] shutdown: cleaning up openhuman-owned ollama if any");
- let shutdown_fut = svc.shutdown_owned_ollama(&runtime);
- if tokio::time::timeout(std::time::Duration::from_secs(2), shutdown_fut)
- .await
- .is_err()
- {
- log::warn!(
- "[core] shutdown: ollama cleanup exceeded 2s budget; proceeding with exit"
- );
- }
- }
+ log::debug!("[core] shutdown: exit cleanup done (no owned local runtime to stop)");
}
/// Spawn each selected background service.
diff --git a/crates/openhuman-core/src/inference/host_runtime/core.rs b/crates/openhuman-core/src/inference/host_runtime/core.rs
index e503aa5faf..d04799e3a9 100644
--- a/crates/openhuman-core/src/inference/host_runtime/core.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/core.rs
@@ -1,10 +1,8 @@
-use std::path::PathBuf;
use std::sync::Arc;
use crate::config::Config;
use super::service::LocalAiService;
-use tinyinference_local::models::effective_chat_model_id;
static LOCAL_AI: once_cell::sync::OnceCell<Arc<LocalAiService>> = once_cell::sync::OnceCell::new();
@@ -15,28 +13,6 @@ pub fn global(config: &Config) -> Arc<LocalAiService> {
.clone()
}
-/// Like [`global`] but returns `None` instead of initialising the singleton.
-///
-/// Useful from shutdown paths where lazy-creating the service just to call a
-/// no-op cleanup would be wasteful — if local AI was never used in this
-/// process, there's nothing to clean up.
-pub fn try_global() -> Option<Arc<LocalAiService>> {
- LOCAL_AI.get().cloned()
-}
-
-pub fn model_artifact_path(config: &Config) -> PathBuf {
- let root = crate::config::default_root_openhuman_dir().unwrap_or_else(|_| {
- config
- .config_path
- .parent()
- .map(std::path::PathBuf::from)
- .unwrap_or_else(|| config.workspace_dir.clone())
- });
- root.join("models")
- .join("local-ai")
- .join(effective_chat_model_id(config).replace(':', "-") + ".ollama")
-}
-
#[cfg(test)]
#[path = "core_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/inference/host_runtime/core_tests.rs b/crates/openhuman-core/src/inference/host_runtime/core_tests.rs
index 300dc1f52c..b5027feef8 100644
--- a/crates/openhuman-core/src/inference/host_runtime/core_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/core_tests.rs
@@ -1,43 +1,5 @@
use super::*;
-#[test]
-fn model_artifact_path_includes_models_local_ai_subdirs() {
- let config = Config::default();
- let path = model_artifact_path(&config);
- let path_str = path.to_string_lossy();
- assert!(
- path_str.contains("models"),
- "expected `models` in path: {path_str}"
- );
- assert!(
- path_str.contains("local-ai"),
- "expected `local-ai` subdir in path: {path_str}"
- );
-}
-
-#[test]
-fn model_artifact_path_ends_with_ollama_suffix() {
- let config = Config::default();
- let path = model_artifact_path(&config);
- assert_eq!(
- path.extension().and_then(|s| s.to_str()),
- Some("ollama"),
- "model artifact must have `.ollama` extension: {}",
- path.display()
- );
-}
-
-#[test]
-fn model_artifact_path_replaces_colon_in_model_id_with_dash() {
- // Model IDs commonly look like `qwen2:1.5b`; colons are illegal on
- // Windows path components, so we normalise to `-`. This test pins
- // that mapping.
- let config = Config::default();
- let path = model_artifact_path(&config);
- let file = path.file_name().unwrap().to_string_lossy().to_string();
- assert!(!file.contains(':'), "filename must not contain `:`: {file}");
-}
-
#[test]
fn global_returns_same_arc_across_calls() {
let config = Config::default();
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
index 736883b517..cd13a47862 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
@@ -100,13 +100,6 @@ async fn local_ai_status_reports_even_when_disabled() {
let _ = result;
}
-#[tokio::test]
-async fn local_ai_assets_status_returns_without_panic() {
- let tmp = tempfile::tempdir().unwrap();
- let config = test_config(&tmp);
- let _ = local_ai_assets_status(&config).await;
-}
-
// ── normalize_model_override (TAURI-RUST-RS) ───────────────────────────
#[test]