Skip to content

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

feat(boot): register composio curated tools at startup

Steven Enamakele4c0c64ddfbe
diff --git a/crates/openhuman-core/src/integrations/composio/contract/curated_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/curated_tests.rs
index f8e2ac9a1a..56a5d88df9 100644
--- a/crates/openhuman-core/src/integrations/composio/contract/curated_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/contract/curated_tests.rs
@@ -114,3 +114,16 @@ fn fixture_agent_ready_list_names_the_native_providers() {
assert!(slugs.iter().any(|s| s == native), "{native} missing");
}
}
+
+#[test]
+fn invalidating_drops_an_installed_snapshot() {
+ // A re-resolved module may serve other tables; the host must not keep
+ // answering from the old ones. (Under test an empty store reads the frozen
+ // module fixture, which has no `invalidatekit`.)
+ let (_, mut vocabulary) = reply();
+ vocabulary.toolkits[0].toolkit = "invalidatekit".into();
+ install_for_test(&[], &vocabulary);
+ assert!(catalog_for_toolkit("invalidatekit").is_some());
+ invalidate();
+ assert!(catalog_for_toolkit("invalidatekit").is_none());
+}
diff --git a/crates/openhuman-core/src/modules/boot.rs b/crates/openhuman-core/src/modules/boot.rs
index fd55159aa6..afffe9be09 100644
--- a/crates/openhuman-core/src/modules/boot.rs
+++ b/crates/openhuman-core/src/modules/boot.rs
@@ -89,13 +89,15 @@ pub async fn load_declared_modules(config: &Config) {
/// started when the user turned Composio off or the connector component is
/// disabled.
fn warm_connector_catalogs(config: &Config) {
- use crate::config::schema::COMPOSIO_MODE_DISABLED;
- if config.composio.mode.trim() == COMPOSIO_MODE_DISABLED
- || ops::disabled_component(config, super::connectors::MODULE_ID).is_some()
- {
+ if !should_warm_connector_catalogs(config) {
log::debug!("[modules] connector catalog warm-up skipped: connectors are off");
return;
}
+ // Unit tests share one process-wide module slot; a detached load started by
+ // every boot test would race the tests that own it.
+ if cfg!(test) {
+ return;
+ }
let config = config.clone();
tokio::spawn(async move {
log::debug!("[modules] connector catalog warm-up starting");
@@ -107,6 +109,14 @@ fn warm_connector_catalogs(config: &Config) {
});
}
+/// Whether the connectors are on: Composio is not switched off and the
+/// connector component is not disabled.
+fn should_warm_connector_catalogs(config: &Config) -> bool {
+ use crate::config::schema::COMPOSIO_MODE_DISABLED;
+ config.composio.mode.trim() != COMPOSIO_MODE_DISABLED
+ && ops::disabled_component(config, super::connectors::MODULE_ID).is_none()
+}
+
#[cfg(test)]
#[path = "boot_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/modules/boot_tests.rs b/crates/openhuman-core/src/modules/boot_tests.rs
index 910b6bdc5e..8440001d57 100644
--- a/crates/openhuman-core/src/modules/boot_tests.rs
+++ b/crates/openhuman-core/src/modules/boot_tests.rs
@@ -38,3 +38,15 @@ async fn boot_skips_disabled_components() {
);
}
}
+
+#[test]
+fn the_catalog_warm_up_runs_only_while_connectors_are_on() {
+ use super::should_warm_connector_catalogs;
+ let mut config = Config::default();
+ assert!(should_warm_connector_catalogs(&config));
+ config.composio.mode = crate::config::schema::COMPOSIO_MODE_DISABLED.into();
+ assert!(
+ !should_warm_connector_catalogs(&config),
+ "composio off must not load the connector module at boot"
+ );
+}