Skip to content

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

refactor(agent): extract ConfigEdit type alias for the config escape hatch

Steven Enamakel47d6abb2c859
diff --git a/crates/openhuman-embed/src/agent/spec.rs b/crates/openhuman-embed/src/agent/spec.rs
index f20257dcf0..3232929e6c 100644
--- a/crates/openhuman-embed/src/agent/spec.rs
+++ b/crates/openhuman-embed/src/agent/spec.rs
@@ -18,6 +18,9 @@ use openhuman_core::tools::toolpacks::ToolGroups;
use super::AgentDefinitionSpec;
use crate::harness::{Access, Provider};
+/// The [`AgentSpec::config`] escape hatch, applied last onto the agent's config.
+type ConfigEdit = Box<dyn FnOnce(&mut Config) + Send>;
+
/// Where [`AgentSpec::skills_dir`] bundles are copied.
#[cfg(feature = "skills")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -50,7 +53,7 @@ pub struct AgentSpec {
action_dir: Option<PathBuf>,
trusted: Vec<(String, TrustedAccess)>,
dedicated_memory: bool,
- config_fn: Option<Box<dyn FnOnce(&mut Config) + Send>>,
+ config_fn: Option<ConfigEdit>,
}
impl AgentSpec {
@@ -295,7 +298,7 @@ pub(crate) struct AgentSpecParts {
pub(crate) action_dir: Option<PathBuf>,
pub(crate) trusted: Vec<(String, TrustedAccess)>,
pub(crate) dedicated_memory: bool,
- pub(crate) config_fn: Option<Box<dyn FnOnce(&mut Config) + Send>>,
+ pub(crate) config_fn: Option<ConfigEdit>,
}
impl std::fmt::Debug for AgentSpec {
diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rs
index 47aa9e512e..2bdddb81ac 100644
--- a/crates/openhuman-embed/tests/runtime_agents.rs
+++ b/crates/openhuman-embed/tests/runtime_agents.rs
@@ -370,9 +370,9 @@ fn one_runtime_hosts_independently_configured_agents() {
drop(alpha);
drop(beta);
drop(_gamma_again);
- let runtime = std::sync::Arc::try_unwrap(runtime)
- .ok()
- .expect("sole owner");
+ let Ok(runtime) = std::sync::Arc::try_unwrap(runtime) else {
+ panic!("the test is the runtime's sole owner once every agent is dropped");
+ };
drop(runtime);
assert!(
!workspace_dir.exists(),