Skip to content

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

refactor(composio): drop tool context from connectable toolkit provider

Steven Enamakel9557ded102fc
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 823e27dcc5..6df3f861dc 100644
--- a/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
@@ -11,7 +11,6 @@ impl crate::integrations::composio::builder_tools::ConnectableToolkitProvider
{
async fn connected(
&self,
- _tool_context: Option<&dyn tinytools::ToolRunContext>,
dispatch: &crate::core::runtime::DispatchCtx,
config: &crate::config::Config,
) -> Vec<String> {
diff --git a/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs b/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
index d8db01a9a9..324bbb64ee 100644
--- a/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
+++ b/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
@@ -23,7 +23,6 @@ pub trait FlowConnectionProvider: Send + Sync {
pub trait ConnectableToolkitProvider: Send + Sync {
async fn connected(
&self,
- tool_context: Option<&dyn ToolRunContext>,
dispatch: &crate::core::runtime::DispatchCtx,
config: &Config,
) -> Vec<String>;
@@ -146,10 +145,7 @@ impl Tool for ListConnectableToolkitsTool {
// read through the host's curated snapshot.
use crate::integrations::composio::contract::agent_ready_toolkits;
tracing::debug!(target: "flows", "[flows] list_connectable_toolkits: listing toolkits + connected state (read-only) via the memory contract");
- let connected = self
- .provider
- .connected(tool_context, &ctx, &self.config)
- .await;
+ let connected = self.provider.connected(&ctx, &self.config).await;
let toolkits: Vec<Value> = agent_ready_toolkits()
.into_iter()
.map(|tk| {
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 fd17c256d0..bc5686e78e 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
@@ -11,29 +11,20 @@ use tempfile::TempDir;
use tinytools::{PermissionLevel, Tool};
struct EmptyConnectableProvider {
- observed_thread_id: Arc<std::sync::Mutex<Option<String>>>,
-}
-
-struct TestToolContext {
- thread_id: String,
-}
-
-impl tinytools::ToolRunContext for TestToolContext {
- fn thread_id(&self) -> Option<&str> {
- Some(&self.thread_id)
- }
+ expected_core: Arc<crate::core::runtime::CoreContext>,
}
#[async_trait::async_trait]
impl ConnectableToolkitProvider for EmptyConnectableProvider {
async fn connected(
&self,
- tool_context: Option<&dyn tinytools::ToolRunContext>,
- _dispatch: &crate::core::runtime::DispatchCtx,
+ dispatch: &crate::core::runtime::DispatchCtx,
_config: &Config,
) -> Vec<String> {
- *self.observed_thread_id.lock().unwrap() =
- tool_context.and_then(tinytools::ToolRunContext::thread_id).map(str::to_string);
+ assert!(Arc::ptr_eq(
+ dispatch.core().expect("tool run core must reach provider"),
+ &self.expected_core,
+ ));
Vec::new()
}
}
@@ -41,16 +32,21 @@ 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 observed_thread_id = Arc::new(std::sync::Mutex::new(None));
+ let core = crate::core::runtime::CoreContext::for_test(
+ crate::core::runtime::DomainSet::full(),
+ None,
+ );
let tool = ListConnectableToolkitsTool::new(
test_config(&tmp),
- Arc::new(EmptyConnectableProvider {
- observed_thread_id: observed_thread_id.clone(),
- }),
+ Arc::new(EmptyConnectableProvider { expected_core: core.clone() }),
+ );
+ let run = crate::agent::tinyagents::host::run_context::OpenHumanRunContext::new()
+ .with_core(Some(core.clone()))
+ .into_tinyagents(tinyagents_harness::context::RunConfig::new("composio-provider-test"));
+ let context = tinyagents_harness::tool::ToolExecutionContext::from_run_context(
+ &run,
+ tinyagents_harness::ids::CallId::new("composio-provider-call"),
);
- let context = TestToolContext {
- thread_id: "captured-tool-run".into(),
- };
let result = tool
.execute_with_context(
json!({}),
@@ -66,7 +62,6 @@ async fn connectable_toolkits_uses_the_injected_host_snapshot_and_fails_closed_e
.unwrap()
.iter()
.all(|item| item["connected"] == false));
- assert_eq!(*observed_thread_id.lock().unwrap(), Some("captured-tool-run".into()));
}
fn test_config(tmp: &TempDir) -> Arc<Config> {