Skip to content

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

fix: preserve explicit embedding opt-out across config migrations

Steven Enamakel531361441007
diff --git a/crates/openhuman-cli/Cargo.toml b/crates/openhuman-cli/Cargo.toml
index d2736b4d9c..db126e5b9f 100644
--- a/crates/openhuman-cli/Cargo.toml
+++ b/crates/openhuman-cli/Cargo.toml
@@ -398,3 +398,7 @@ bin-tools = ["dep:clap"]
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }
+
+[[test]]
+name = "embeddings_opt_out"
+path = "../../tests/embeddings_opt_out.rs"
diff --git a/crates/openhuman-core/src/config/migrations/reconcile_orphaned_providers.rs b/crates/openhuman-core/src/config/migrations/reconcile_orphaned_providers.rs
index 666d95e43a..2a4c7bb7f4 100644
--- a/crates/openhuman-core/src/config/migrations/reconcile_orphaned_providers.rs
+++ b/crates/openhuman-core/src/config/migrations/reconcile_orphaned_providers.rs
@@ -108,7 +108,9 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {
// lmstudio:, mlx:, omlx:, local-openai:) resolve without a
// cloud_providers entry — leave them alone. Keep this in sync with the
// local provider prefixes the factory accepts.
- if s.is_empty()
+ // Only embeddings accept `none` as an explicit opt-out.
+ if (workload == "embeddings" && s == "none")
+ || s.is_empty()
|| s == "cloud"
|| s == PROVIDER_OPENHUMAN
|| s.starts_with(OLLAMA_PROVIDER_PREFIX)
diff --git a/crates/openhuman-core/src/config/schema/load/migrate.rs b/crates/openhuman-core/src/config/schema/load/migrate.rs
index 8b2dce9d48..3c13855ac9 100644
--- a/crates/openhuman-core/src/config/schema/load/migrate.rs
+++ b/crates/openhuman-core/src/config/schema/load/migrate.rs
@@ -164,7 +164,15 @@ pub(crate) fn migrate_cloud_provider_slugs(config: &mut Config) {
rewrite(&mut config.coding_provider);
rewrite(&mut config.vision_provider);
rewrite(&mut config.memory_provider);
- rewrite(&mut config.embeddings_provider);
+ // Embeddings have a deliberate opt-out, not a cloud-provider slug.
+ // Preserve it on every load, including whitespace the settings RPC trims.
+ if !config
+ .embeddings_provider
+ .as_deref()
+ .is_some_and(|provider| provider.trim() == "none")
+ {
+ rewrite(&mut config.embeddings_provider);
+ }
fn normalize_provider_endpoint(url: &str) -> String {
url.trim().trim_end_matches('/').to_ascii_lowercase()
diff --git a/tests/embeddings_opt_out.rs b/tests/embeddings_opt_out.rs
new file mode 100644
index 0000000000..3dc6f14e2e
--- /dev/null
+++ b/tests/embeddings_opt_out.rs
@@ -0,0 +1,60 @@
+//! Config loading and versioned migration must preserve the embedding opt-out.
+
+use openhuman_core::config::{migrations, Config};
+
+#[tokio::test]
+async fn disk_config_keeps_embeddings_disabled_on_repeated_loads() {
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+ let workspace = dir.path().join("workspace");
+ std::fs::write(
+ &config_path,
+ "embeddings_provider = \"none\"\n[memory]\nembedding_provider = \"none\"\nengine = \"\"\n",
+ )
+ .unwrap();
+
+ for _ in 0..2 {
+ let config = Config::load_from_config_path(&config_path, &workspace)
+ .await
+ .unwrap();
+ assert_eq!(config.embeddings_provider.as_deref(), Some("none"));
+ assert_eq!(config.memory.embedding_provider, "none");
+ config.save().await.unwrap();
+ }
+}
+
+#[tokio::test]
+async fn versioned_migrations_keep_embedding_opt_out_without_a_cloud_provider_entry() {
+ let dir = tempfile::tempdir().unwrap();
+ let mut config = Config {
+ config_path: dir.path().join("config.toml"),
+ workspace_dir: dir.path().join("workspace"),
+ action_dir: dir.path().join("actions"),
+ schema_version: 4,
+ embeddings_provider: Some("none".into()),
+ reasoning_provider: Some("none".into()),
+ ..Config::default()
+ };
+ config.memory.embedding_provider = "none".into();
+ config.memory.engine.clear();
+
+ migrations::run_pending(&mut config).await;
+
+ assert_eq!(config.embeddings_provider.as_deref(), Some("none"));
+ assert_eq!(config.reasoning_provider, None);
+ let reloaded = Config::load_from_config_path(&config.config_path, &config.workspace_dir)
+ .await
+ .unwrap();
+ assert_eq!(reloaded.embeddings_provider.as_deref(), Some("none"));
+}
+
+#[tokio::test]
+async fn unknown_embedding_routes_still_fall_back_to_managed() {
+ let dir = tempfile::tempdir().unwrap();
+ let config_path = dir.path().join("config.toml");
+ std::fs::write(&config_path, "embeddings_provider = \"removed-provider\"\n").unwrap();
+ let config = Config::load_from_config_path(&config_path, &dir.path().join("workspace"))
+ .await
+ .unwrap();
+ assert_eq!(config.embeddings_provider.as_deref(), Some("openhuman"));
+}