Skip to content

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

test(config): add test for blank chat agent id clearing override

Steven Enamakel762ce7689eb7
diff --git a/crates/openhuman-core/src/config/ops_agent_paths_tests.rs b/crates/openhuman-core/src/config/ops_agent_paths_tests.rs
index 5fdffdb0d7..e129a6b855 100644
--- a/crates/openhuman-core/src/config/ops_agent_paths_tests.rs
+++ b/crates/openhuman-core/src/config/ops_agent_paths_tests.rs
@@ -69,6 +69,35 @@ async fn apply_agent_settings_rejects_unknown_chat_agent_id() {
assert!(cfg.agent.chat_agent_id.is_none());
}
+#[tokio::test]
+async fn apply_agent_settings_blank_chat_agent_id_clears_and_persists_override() {
+ let _g = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
+ let tmp = tempdir().unwrap();
+ let mut cfg = tmp_config(&tmp);
+ cfg.agent.chat_agent_id = Some("researcher".into());
+
+ let outcome = apply_agent_settings(
+ &mut cfg,
+ AgentSettingsPatch {
+ chat_agent_id: Some(" ".into()),
+ ..AgentSettingsPatch::default()
+ },
+ )
+ .await
+ .expect("blank chat agent id clears the override");
+
+ assert_eq!(cfg.agent.chat_agent_id, None);
+ assert_eq!(outcome.value["config"]["agent"]["chat_agent_id"], serde_json::Value::Null);
+
+ let saved = tokio::fs::read_to_string(&cfg.config_path)
+ .await
+ .expect("saved config");
+ assert!(
+ !saved.contains("chat_agent_id"),
+ "cleared override must not remain in the persisted config: {saved}"
+ );
+}
+
#[tokio::test]
async fn apply_agent_settings_rejects_a_mixed_patch_without_mutating_config() {
let _g = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());