Skip to content

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

test(composio): assert run context reaches injected toolkit provider

Steven Enamakel6e626f437b07
diff --git a/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs b/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
index 0dfc570a8e..6df3f861dc 100644
--- a/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
@@ -14,7 +14,10 @@ impl crate::integrations::composio::builder_tools::ConnectableToolkitProvider
dispatch: &crate::core::runtime::DispatchCtx,
config: &crate::config::Config,
) -> Vec<String> {
- crate::flows::ops::connected_toolkits(dispatch, config).await
+ crate::flows::ops::connected_toolkits(dispatch, config)
+ .await
+ .into_iter()
+ .collect()
}
}
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
index 5873efa995..e520ada9dc 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio.rs
@@ -59,7 +59,7 @@ impl FlowCallPolicy for FlowPolicy {
let display_error = result
.as_ref()
.err()
- .map(|message| EngineError::Capability(message.clone()).to_string());
+ .map(|message| capability_error_display(message));
gate.record_execution(audit_id, outcome, display_error.as_deref());
}
}
@@ -72,6 +72,14 @@ fn capability_payload(error: EngineError) -> String {
}
}
+fn capability_error_display(message: &str) -> String {
+ EngineError::Capability(message.to_string()).to_string()
+}
+
+#[cfg(test)]
+#[path = "composio_adapter_tests.rs"]
+mod tests;
+
#[async_trait]
impl ToolBackend for ComposioToolBackend {
fn name(&self) -> &'static str {
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio_adapter_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio_adapter_tests.rs
new file mode 100644
index 0000000000..b204f718f8
--- /dev/null
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tools/composio_adapter_tests.rs
@@ -0,0 +1,11 @@
+use super::*;
+
+#[test]
+fn capability_payload_and_audit_display_match_the_original_error_envelope() {
+ let payload = capability_payload(EngineError::Capability("blocked by autonomy tier".into()));
+ assert_eq!(payload, "blocked by autonomy tier");
+ assert_eq!(
+ capability_error_display(&payload),
+ EngineError::Capability("blocked by autonomy tier".into()).to_string()
+ );
+}
diff --git a/crates/openhuman-core/src/integrations/composio/builder_tools/owner_tools_tests.rs b/crates/openhuman-core/src/integrations/composio/builder_tools/owner_tools_tests.rs
index ac28dbd296..e713e2bd6c 100644
--- a/crates/openhuman-core/src/integrations/composio/builder_tools/owner_tools_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/builder_tools/owner_tools_tests.rs
@@ -10,15 +10,18 @@ use std::sync::Arc;
use tempfile::TempDir;
use tinytools::{PermissionLevel, Tool};
-struct EmptyConnectableProvider;
+struct EmptyConnectableProvider {
+ observed_tier_source: Arc<std::sync::Mutex<Option<crate::core::runtime::AutonomyTierSource>>>,
+}
#[async_trait::async_trait]
impl ConnectableToolkitProvider for EmptyConnectableProvider {
async fn connected(
&self,
- _dispatch: &crate::core::runtime::DispatchCtx,
+ dispatch: &crate::core::runtime::DispatchCtx,
_config: &Config,
) -> Vec<String> {
+ *self.observed_tier_source.lock().unwrap() = Some(dispatch.autonomy_tier_source());
Vec::new()
}
}
@@ -26,8 +29,13 @@ impl ConnectableToolkitProvider for EmptyConnectableProvider {
#[tokio::test]
async fn connectable_toolkits_uses_the_injected_host_snapshot_and_fails_closed_empty() {
let tmp = TempDir::new().unwrap();
- let tool =
- ListConnectableToolkitsTool::new(test_config(&tmp), Arc::new(EmptyConnectableProvider));
+ let observed_tier_source = Arc::new(std::sync::Mutex::new(None));
+ let tool = ListConnectableToolkitsTool::new(
+ test_config(&tmp),
+ Arc::new(EmptyConnectableProvider {
+ observed_tier_source: observed_tier_source.clone(),
+ }),
+ );
let result = tool.execute(json!({})).await.unwrap();
assert!(!result.is_error, "{}", result.output());
let value: Value = serde_json::from_str(&result.output()).unwrap();
@@ -36,6 +44,11 @@ async fn connectable_toolkits_uses_the_injected_host_snapshot_and_fails_closed_e
.unwrap()
.iter()
.all(|item| item["connected"] == false));
+ assert_eq!(
+ *observed_tier_source.lock().unwrap(),
+ Some(crate::core::runtime::DispatchCtx::ambient().autonomy_tier_source()),
+ "the run context must reach the injected source"
+ );
}
fn test_config(tmp: &TempDir) -> Arc<Config> {