Skip to content

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

feat(composio): add connection management operations

Steven Enamakel3598815433d2
diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
index 57767148f4..323a11f04c 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
@@ -42,7 +42,7 @@ pub async fn composio_list_connections(
// No session means no proxy route, so the connector module cannot
// answer — but the connections may well exist server-side. That makes
// this "unavailable", not "none": callers that tell the two apart
- // (`memory::sources::reconcile` hides nothing on `Err`,
+ // (`the connection cache hides nothing on `Err`,
// `flows::validate_connection_refs` fails open on `Err`) must keep
// doing so, which an empty `Ok` would silently defeat. It is also not
// a fault, so it is not reported here: nothing reaches Sentry for a
@@ -148,27 +148,31 @@ pub async fn composio_authorize(
))
}
+/// The `composio.delete_connection` reply.
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct ComposioDeleteResult {
+ /// Whether the backend confirmed the deletion.
+ pub deleted: bool,
+}
+
pub async fn composio_delete_connection(
config: &Config,
connection_id: &str,
- clear_memory: bool,
-) -> OpResult<Outcome<ComposioDeleteResponse>> {
+) -> OpResult<Outcome<ComposioDeleteResult>> {
tracing::debug!(connection_id = %connection_id, "[composio] rpc delete_connection");
- // The toolkit names the identity facets to drop;
- // forgetting memory needs only the connection id (its records carry a
- // `connection:<id>` tag), so an unresolvable toolkit skips the former only.
+ // The toolkit names the identity facets to drop; an unresolvable toolkit
+ // skips that cleanup only.
let toolkit = resolve_toolkit_for_connection(config, connection_id)
.await
.ok();
- // Only the Composio-side removal crosses the bus. Everything around it —
- // the synced memory and the identity facets — is this host's own
- // bookkeeping about a connection it no longer has.
- let mut resp = connectors::call::<_, ComposioDeleteResponse>(
+ // Only the Composio-side removal crosses the bus. The identity facets
+ // are this host's own bookkeeping about a connection it no longer has.
+ let resp = connectors::call::<_, ComposioDeleteResponse>(
config,
methods::DELETE_CONNECTION,
ComposioDeleteConnectionRequest {
connection_id: connection_id.to_string(),
- clear_memory,
+ clear_memory: false,
},
)
.await
@@ -176,31 +180,6 @@ pub async fn composio_delete_connection(
report_composio_op_error("delete_connection", &anyhow::anyhow!("{error}"));
format!("[composio] delete_connection failed: {error}")
})?;
- let mut memory_clear_error = None;
- if clear_memory {
- match crate::memory::sources::composio::forget_connection(
- config,
- connection_id,
- toolkit.as_deref(),
- )
- .await
- {
- Ok(forgotten) => {
- tracing::debug!(
- connection_id = %connection_id,
- forgotten,
- "[composio] forgot memory synced through the deleted connection"
- );
- resp.memory_chunks_deleted = forgotten;
- }
- Err(error) => {
- memory_clear_error = Some(format!(
- "[composio] connection deleted, but failed to clear its memory: {}",
- String::from(error)
- ));
- }
- }
- }
if let Some(toolkit) = toolkit.as_deref() {
let deleted = delete_connected_identity_facets(config, toolkit, connection_id)
.await
@@ -242,11 +221,10 @@ pub async fn composio_delete_connection(
);
}
}
- if let Some(error) = memory_clear_error {
- return Err(error);
- }
Ok(Outcome::new(
- resp,
+ ComposioDeleteResult {
+ deleted: resp.deleted,
+ },
vec![format!("composio: connection {connection_id} deleted")],
))
}
diff --git a/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs b/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
index 1b653e66ef..48f1494eed 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
@@ -85,8 +85,7 @@ pub(crate) fn direct_mode_without_key(config: &Config) -> OpResult<bool> {
/// [`COMPOSIO_NO_SESSION`] error instead — deliberately not an empty list,
/// unlike the direct-mode guard: no key means no tenant and truly no
/// connections, whereas no session only means the connections cannot be
-/// reached yet, and `memory::sources::reconcile` /
-/// `flows::validate_connection_refs` rely on `Err` meaning "unknown" (fail
+/// reached yet, and `flows::validate_connection_refs` rely on `Err` meaning "unknown" (fail
/// open) rather than "none".
///
/// Credential presence MUST mirror the module route's own resolution:
diff --git a/crates/openhuman-core/src/integrations/composio/ops/mod.rs b/crates/openhuman-core/src/integrations/composio/ops/mod.rs
index 235e3b3aca..66533c5cb8 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/mod.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/mod.rs
@@ -36,7 +36,7 @@ mod user_scopes;
pub use connections::{
active_connection_ids, composio_authorize, composio_delete_connection,
- composio_list_connections,
+ composio_list_connections, ComposioDeleteResult,
};
pub use direct_mode::{composio_clear_api_key, composio_get_mode, composio_set_api_key};
pub(crate) use error_utils::{report_composio_op_error, should_forward_tags};
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/definitions.rs b/crates/openhuman-core/src/integrations/composio/schemas/definitions.rs
index ae6ec4afa9..43627be455 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/definitions.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/definitions.rs
@@ -98,7 +98,7 @@ pub fn schemas(function: &str) -> ControllerSchema {
"delete_connection" => ControllerSchema {
namespace: "composio",
function: "delete_connection",
- description: "Delete a Composio connection and optionally forget the memory synced through it.",
+ description: "Delete a Composio connection.",
inputs: vec![
FieldSchema {
name: "connection_id",
@@ -106,12 +106,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
comment: "Identifier of the connection to delete.",
required: true,
},
- FieldSchema {
- name: "clear_memory",
- ty: TypeSchema::Bool,
- comment: "When true, forget the memory items synced through this connection.",
- required: false,
- },
],
outputs: vec![
FieldSchema {
@@ -120,12 +114,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
comment: "True when the backend confirmed the deletion.",
required: true,
},
- FieldSchema {
- name: "memory_chunks_deleted",
- ty: TypeSchema::U64,
- comment: "Number of memory items forgotten for this connection.",
- required: true,
- },
],
},
"list_tools" => ControllerSchema {
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 5bffd58b0f..baf5d8e6b5 100644
--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs
@@ -49,8 +49,7 @@ pub(super) fn handle_delete_connection(params: Map<String, Value>) -> Controller
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
let connection_id = read_required_non_empty(&params, "connection_id")?;
- let clear_memory = read_optional::<bool>(&params, "clear_memory")?.unwrap_or(false);
- to_json(ops::composio_delete_connection(&config, &connection_id, clear_memory).await?)
+ to_json(ops::composio_delete_connection(&config, &connection_id).await?)
})
}