Skip to content

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

fix: correct test assertion for env overlay precedence

Steven Enamakel4b884886dd99
diff --git a/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs b/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
index c3734c4be2..228e370935 100644
--- a/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
@@ -686,3 +686,65 @@ fn env_overlay_tool_dispatcher_overrides_the_agent_field_when_non_blank() {
cfg.apply_env_overlay_with(&HashMapEnv::new().with("OPENHUMAN_TOOL_DISPATCHER", ""));
assert_eq!(cfg.agent.tool_dispatcher, "native");
}
+
+/// Local model tier presets were removed: OpenHuman no longer picks models by
+/// RAM tier. A stale `OPENHUMAN_LOCAL_AI_TIER` in the environment must be
+/// ignored rather than rewriting the user's configured local models.
+#[test]
+fn env_overlay_ignores_removed_local_ai_tier_var() {
+ let env = HashMapEnv::new().with("OPENHUMAN_LOCAL_AI_TIER", "ram_2_4gb");
+ let mut cfg = Config::default();
+ cfg.local_ai.chat_model_id = "llama3.1:8b".to_string();
+ cfg.local_ai.embedding_model_id = "nomic-embed-text:latest".to_string();
+ cfg.apply_env_overlay_with(&env);
+ assert_eq!(cfg.local_ai.chat_model_id, "llama3.1:8b");
+ assert_eq!(cfg.local_ai.embedding_model_id, "nomic-embed-text:latest");
+}
+
+/// A config.toml written while OpenHuman still downloaded local models carries
+/// tier, quantization, preload, binary-path and download-URL keys under
+/// `[local_ai]`. Those keys are no longer read, but such a file must still
+/// load with the user's endpoint and model choices intact.
+#[test]
+fn legacy_local_ai_download_keys_still_load() {
+ let legacy = r#"
+api_url = "http://127.0.0.1:9"
+
+[local_ai]
+runtime_enabled = true
+opt_in_confirmed = true
+provider = "ollama"
+base_url = "http://127.0.0.1:11434"
+chat_model_id = "llama3.1:8b"
+embedding_model_id = "bge-m3"
+selected_tier = "ram_2_4gb"
+quantization = "q4_k_m"
+preload_vision_model = true
+preload_embedding_model = true
+preload_stt_model = false
+preload_tts_voice = false
+ollama_binary_path = "/opt/openhuman/bin/ollama"
+download_url = "https://example.invalid/model.gguf"
+stt_download_url = "https://example.invalid/stt.bin"
+tts_download_url = "https://example.invalid/voice.onnx"
+tts_config_download_url = "https://example.invalid/voice.onnx.json"
+"#;
+ let cfg: Config = toml::from_str(legacy).expect("legacy local_ai keys must still parse");
+ assert!(cfg.local_ai.runtime_enabled);
+ assert!(cfg.local_ai.opt_in_confirmed);
+ assert_eq!(cfg.local_ai.provider, "ollama");
+ assert_eq!(
+ cfg.local_ai.base_url.as_deref(),
+ Some("http://127.0.0.1:11434")
+ );
+ assert_eq!(cfg.local_ai.chat_model_id, "llama3.1:8b");
+ assert_eq!(cfg.local_ai.embedding_model_id, "bge-m3");
+
+ // The runtime projection carries only endpoint and model settings.
+ let runtime = crate::inference::local_runtime_config(&cfg);
+ assert_eq!(runtime.local_ai.chat_model_id, "llama3.1:8b");
+ assert_eq!(
+ runtime.local_ai.base_url.as_deref(),
+ Some("http://127.0.0.1:11434")
+ );
+}