Skip to content

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

chore(composio): tidy toolkit and connector plumbing

Steven Enamakel21da69cb7e8e
diff --git a/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs b/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs
index b94ba271cd..b02e102877 100644
--- a/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs
@@ -136,6 +136,9 @@ pub(crate) async fn search_catalog(
// re-exported; see `ListConnectableToolkitsTool::execute` for why (#5560).
use crate::integrations::composio::contract::agent_ready_toolkits;
+ // Curated-catalog lookups below read the module's process snapshot.
+ crate::integrations::composio::module_client::ensure_catalogs(config).await;
+
let terms: Vec<String> = query
.split_whitespace()
.map(|t| t.to_ascii_lowercase())
diff --git a/crates/openhuman-core/src/integrations/composio/module_client.rs b/crates/openhuman-core/src/integrations/composio/module_client.rs
index d5e4ec1d35..1bd9afd850 100644
--- a/crates/openhuman-core/src/integrations/composio/module_client.rs
+++ b/crates/openhuman-core/src/integrations/composio/module_client.rs
@@ -100,6 +100,21 @@ async fn prime_curated_catalogs(config: &crate::config::Config) {
}
}
+/// Make sure the curated-catalog snapshot is filled before a synchronous
+/// lookup that does not itself call the module (the agent-ready list, catalog
+/// search). The module is loaded if it is not yet, then asked once per pinned
+/// version; a failure is logged and the lookups read every toolkit as
+/// uncurated until a later call succeeds. A build without a module loader has
+/// no catalogs to read and does nothing.
+#[cfg(feature = "modules")]
+pub async fn ensure_catalogs(config: &crate::config::Config) {
+ prime_curated_catalogs(config).await;
+}
+
+/// Without the module loader there is no catalog to read.
+#[cfg(not(feature = "modules"))]
+pub async fn ensure_catalogs(_config: &crate::config::Config) {}
+
/// Call one member with an argument and decode its reply.
///
/// # Errors
diff --git a/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs b/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs
index 08d3e2dac2..259f2d0624 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs
@@ -77,8 +77,12 @@ pub async fn composio_list_capabilities(
/// "preview / agent integration coming soon" so users aren't led into
/// a broken `composio_list_tools` → max-iterations loop. See #2283.
pub async fn composio_list_agent_ready_toolkits(
+ config: &Config,
) -> OpResult<Outcome<super::super::types::ComposioAgentReadyToolkitsResponse>> {
tracing::debug!("[composio] rpc list_agent_ready_toolkits");
+ // The list is the module's, read through the process snapshot; fill it
+ // first so this does not answer empty ahead of the first connector call.
+ connectors::ensure_catalogs(config).await;
let toolkits: Vec<String> = agent_ready_toolkits();
let count = toolkits.len();
let resp = super::super::types::ComposioAgentReadyToolkitsResponse { toolkits };
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
index baf5d8e6b5..33f811b9b9 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
@@ -26,7 +26,10 @@ pub(super) fn handle_list_capabilities(_params: Map<String, Value>) -> Controlle
}
pub(super) fn handle_list_agent_ready_toolkits(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async { to_json(ops::composio_list_agent_ready_toolkits().await?) })
+ Box::pin(async {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(ops::composio_list_agent_ready_toolkits(&config).await?)
+ })
}
pub(super) fn handle_list_connections(_params: Map<String, Value>) -> ControllerFuture {
diff --git a/crates/openhuman-core/src/modules/boot.rs b/crates/openhuman-core/src/modules/boot.rs
index d380af269d..271e125c97 100644
--- a/crates/openhuman-core/src/modules/boot.rs
+++ b/crates/openhuman-core/src/modules/boot.rs
@@ -74,6 +74,21 @@ pub async fn load_declared_modules(config: &Config) {
);
}
}
+
+ // A connector module that is already serving (found on the search path, so
+ // no resolution ran for it) still needs its catalogs read into the host.
+ if ops::state_of(super::connectors::MODULE_ID) == super::types::ModuleState::Ready
+ || super::host::runtime()
+ .await
+ .is_ok_and(|runtime| {
+ runtime.host().list().iter().any(|info| {
+ registry::find(super::connectors::MODULE_ID)
+ .is_some_and(|record| info.manifest.bus_name.as_str() == record.bus_name)
+ })
+ })
+ {
+ super::connectors::prime_catalogs(config).await;
+ }
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rs
index 70bc3439ee..eb07944e23 100644
--- a/crates/openhuman-core/src/modules/connectors.rs
+++ b/crates/openhuman-core/src/modules/connectors.rs
@@ -196,6 +196,19 @@ fn route_config(config: &Config) -> Result<serde_json::Value, String> {
}
}
+/// Read the connector module's curated catalogs into the host's snapshot.
+///
+/// Called once the module is serving (see `ops::start_resolution`) and at
+/// boot when it was already serving from the search path. A failure only
+/// delays the snapshot: the next connector call primes it again.
+pub async fn prime_catalogs(config: &Config) {
+ if let Err(error) =
+ crate::integrations::composio::contract::curated::prime(config).await
+ {
+ tracing::debug!("[connectors] catalog prime failed: {error}");
+ }
+}
+
/// The route description last sent to the module, as a fingerprint.
///
/// Only a hash is kept: comparing routes means comparing bearer tokens, and a
diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rs
index c395947080..51840befb6 100644
--- a/crates/openhuman-core/src/modules/ops.rs
+++ b/crates/openhuman-core/src/modules/ops.rs
@@ -257,7 +257,20 @@ async fn start_resolution(
Resolution::Failed(reason)
}
};
+ let ready = matches!(resolution, Resolution::Ready);
+ // The connector module's curated catalogs are cached in the host; a
+ // module that has just been (re)resolved may serve other tables, so
+ // drop the snapshot before any waiting caller is released.
+ if id == super::connectors::MODULE_ID {
+ crate::integrations::composio::contract::curated::invalidate();
+ }
resolution::global().complete(id, resolution, sender);
+ if ready && id == super::connectors::MODULE_ID {
+ // Fill it now rather than at the first connector call, so the
+ // synchronous lookups (tool visibility, flow gates) never read an
+ // empty snapshot in between.
+ super::connectors::prime_catalogs(&config).await;
+ }
};
match host::runtime().await {
Ok(runtime) => {