Skip to content

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

refactor(runtime): extract config overlay recording into helper

Steven Enamakeld1d1fbaeeab7
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rs
index 044533170b..2a4e6518e0 100644
--- a/crates/openhuman-core/src/core/runtime/context.rs
+++ b/crates/openhuman-core/src/core/runtime/context.rs
@@ -424,34 +424,7 @@ impl CoreContext {
}
};
let agent = self.agent.derive(&mut overlay);
- let config_overlay = if let Some(profile_id) = overlay.profile.as_deref() {
- let parent_profile_config = (self.profile() == Some(profile_id))
- .then_some(parent_config)
- .flatten();
- Some(
- crate::config::schema::load::context_overlay::ConfigContextOverlay::derive_profile(
- parent_profile_config,
- &overlay.config,
- ),
- )
- } else {
- parent_config.map(|parent_config| {
- crate::config::schema::load::context_overlay::ConfigContextOverlay::derive(
- parent_config,
- &overlay.config,
- )
- })
- };
- if let Some(config_overlay) = config_overlay {
- match config_overlay {
- Ok(config_overlay) => {
- overlay.config.context_overlay = std::sync::Mutex::new(Some(config_overlay));
- }
- Err(error) => {
- log::warn!("[core-context] unable to record derived config overrides: {error}")
- }
- }
- }
+ config_access::record_context_config_overlay(self.profile(), parent_config, &mut overlay);
overlay.config.context_snapshot = None;
let latest_embedder_config = Some(Arc::new(std::sync::Mutex::new(overlay.config.clone())));
if let Some(snapshot) = &latest_embedder_config {
diff --git a/crates/openhuman-core/src/core/runtime/context_config.rs b/crates/openhuman-core/src/core/runtime/context_config.rs
index a88fbe8d28..15adeee26d 100644
--- a/crates/openhuman-core/src/core/runtime/context_config.rs
+++ b/crates/openhuman-core/src/core/runtime/context_config.rs
@@ -1,6 +1,41 @@
use std::sync::Arc;
-use super::CoreContext;
+use super::{ContextOverlay, CoreContext};
+
+pub(super) fn record_context_config_overlay(
+ parent_profile: Option<&str>,
+ parent_config: Option<&crate::config::Config>,
+ overlay: &mut ContextOverlay,
+) {
+ let config_overlay = if let Some(profile_id) = overlay.profile.as_deref() {
+ let parent_profile_config = (parent_profile == Some(profile_id))
+ .then_some(parent_config)
+ .flatten();
+ Some(
+ crate::config::schema::load::context_overlay::ConfigContextOverlay::derive_profile(
+ parent_profile_config,
+ &overlay.config,
+ ),
+ )
+ } else {
+ parent_config.map(|parent_config| {
+ crate::config::schema::load::context_overlay::ConfigContextOverlay::derive(
+ parent_config,
+ &overlay.config,
+ )
+ })
+ };
+ if let Some(config_overlay) = config_overlay {
+ match config_overlay {
+ Ok(config_overlay) => {
+ overlay.config.context_overlay = std::sync::Mutex::new(Some(config_overlay));
+ }
+ Err(error) => {
+ log::warn!("[core-context] unable to record derived config overrides: {error}")
+ }
+ }
+ }
+}
impl CoreContext {
/// The embedder-supplied config for the current dispatch, if there is one.