Skip to content

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

refactor(config): add with_base helper for context overlay

Steven Enamakelaab4a22826cc
diff --git a/crates/openhuman-core/src/config/schema/load/context_overlay.rs b/crates/openhuman-core/src/config/schema/load/context_overlay.rs
index 623d703851..df9260e2c9 100644
--- a/crates/openhuman-core/src/config/schema/load/context_overlay.rs
+++ b/crates/openhuman-core/src/config/schema/load/context_overlay.rs
@@ -26,6 +26,12 @@ impl std::fmt::Debug for ConfigContextOverlay {
}
impl ConfigContextOverlay {
+ pub(crate) fn with_base(&self, base: Value) -> Self {
+ let mut advanced = self.clone();
+ advanced.base = base;
+ advanced
+ }
+
pub(crate) fn derive(parent: &Config, child: &Config) -> anyhow::Result<Arc<Self>> {
let inherited = parent.context_overlay.lock().unwrap().clone();
let (base, mut changes) = match inherited.as_ref() {
diff --git a/crates/openhuman-core/src/config/schema/load/impl_load.rs b/crates/openhuman-core/src/config/schema/load/impl_load.rs
index 70e3c51876..66e9195e40 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -467,8 +467,7 @@ impl Config {
if let Some(base) = overlay_base_after_save {
let existing_overlay = { self.context_overlay.lock().unwrap().clone() };
if let Some(overlay) = existing_overlay {
- let mut advanced = (*overlay).clone();
- advanced.base = base;
+ let advanced = overlay.with_base(base);
*self.context_overlay.lock().unwrap() = Some(std::sync::Arc::new(advanced));
}
}