Skip to content

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

fix(config): handle missing schema branches gracefully

Steven Enamakelfa545c1062df
diff --git a/crates/openhuman-core/src/config/schema/load/branches.rs b/crates/openhuman-core/src/config/schema/load/branches.rs
index 719a42f822..f1f2135871 100644
--- a/crates/openhuman-core/src/config/schema/load/branches.rs
+++ b/crates/openhuman-core/src/config/schema/load/branches.rs
@@ -9,7 +9,8 @@ use super::dirs::{default_action_dir, resolve_action_dir, ConfigResolutionSource
use super::env::EnvLookup;
use super::impl_load::{parse_config_boxed, read_config_with_recovery_or_default};
use super::migrate::{
- migrate_cloud_provider_slugs, migrate_legacy_inference_url, migrate_search_settings,
+ migrate_cloud_provider_slugs, migrate_legacy_inference_url, migrate_legacy_memory_sources,
+ migrate_search_settings,
};
use super::secrets::decrypt_config_secrets;
use anyhow::Result;
@@ -170,6 +171,7 @@ impl Config {
migrate_legacy_inference_url(&mut config);
migrate_cloud_provider_slugs(&mut config);
migrate_search_settings(&mut config);
+ migrate_legacy_memory_sources(&mut config);
config.apply_env_overrides_from(env);
if config_was_corrupted {
diff --git a/crates/openhuman-core/src/config/schema/load/migrate.rs b/crates/openhuman-core/src/config/schema/load/migrate.rs
index 7d49c2126c..503a3f351c 100644
--- a/crates/openhuman-core/src/config/schema/load/migrate.rs
+++ b/crates/openhuman-core/src/config/schema/load/migrate.rs
@@ -213,3 +213,24 @@ pub(crate) fn migrate_search_settings(config: &mut Config) {
};
config.search.migrate_legacy(legacy);
}
+
+/// Migrates legacy v1 `[[memory_sources]]` into `[[memory.sources]]`, once:
+/// only when no v2 source exists yet. Kinds without a v2 equivalent
+/// (`twitter_query`, `conversation`) and disabled entries are dropped. The
+/// legacy list is cleared either way, so it is never written back.
+pub(crate) fn migrate_legacy_memory_sources(config: &mut Config) {
+ let legacy = std::mem::take(&mut config.legacy_memory_sources);
+ if legacy.is_empty() || !config.memory.sources.is_empty() {
+ return;
+ }
+ let migrated: Vec<_> = legacy
+ .iter()
+ .filter_map(super::super::memory::migrate_legacy_source)
+ .collect();
+ tracing::info!(
+ legacy = legacy.len(),
+ migrated = migrated.len(),
+ "[config] migrated legacy memory sources"
+ );
+ config.memory.sources = migrated;
+}
diff --git a/crates/openhuman-core/src/config/schema/load/mod.rs b/crates/openhuman-core/src/config/schema/load/mod.rs
index cb99bf5607..fe5a090c58 100644
--- a/crates/openhuman-core/src/config/schema/load/mod.rs
+++ b/crates/openhuman-core/src/config/schema/load/mod.rs
@@ -55,7 +55,9 @@ pub(crate) use dirs::ACTIVE_USER_STATE_FILE;
#[cfg(test)]
pub(crate) use impl_load::parse_config_with_recovery;
#[cfg(test)]
-pub(crate) use migrate::{migrate_cloud_provider_slugs, migrate_legacy_inference_url};
+pub(crate) use migrate::{
+ migrate_cloud_provider_slugs, migrate_legacy_inference_url, migrate_legacy_memory_sources,
+};
#[cfg(test)]
pub(crate) use std::path::PathBuf;