Skip to content

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

fix(memory): treat an aliased Composio source as a duplicate

M3gA-Mind36083813c9cf
diff --git a/crates/openhuman-core/src/memory/sources/mod.rs b/crates/openhuman-core/src/memory/sources/mod.rs
index fa5a212046..94b3bea980 100644
--- a/crates/openhuman-core/src/memory/sources/mod.rs
+++ b/crates/openhuman-core/src/memory/sources/mod.rs
@@ -122,11 +122,19 @@ pub fn apply_add(
)));
}
}
+ // A Composio target saved before targets were canonicalized
+ // (`google_drive`) is the same toolkit as its canonical slug.
+ let same_target = |saved: &str| match kind {
+ MemorySourceKind::Composio => {
+ crate::integrations::composio::tools::canonicalize_toolkit_slug(saved) == target
+ }
+ _ => saved == target,
+ };
if config
.memory
.sources
.iter()
- .any(|source| source.kind == kind && source.target == target)
+ .any(|source| source.kind == kind && same_target(&source.target))
{
return Err(MemoryError::invalid("that source is already added"));
}
diff --git a/crates/openhuman-core/src/memory/sources/mod_tests.rs b/crates/openhuman-core/src/memory/sources/mod_tests.rs
index 9b8168110e..5cb7e6465a 100644
--- a/crates/openhuman-core/src/memory/sources/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/mod_tests.rs
@@ -161,6 +161,21 @@ fn add_validates_kind_schedule_and_target() {
// A Composio source needs no reader.
apply_add(&mut config, &add_params("composio", "Gmail")).unwrap();
assert_eq!(config.memory.sources[0].target, "gmail");
+
+ // A source saved under an alias before canonicalization is still the
+ // same toolkit.
+ config.memory.sources.push(MemorySourceConfig {
+ kind: MemorySourceKind::Composio,
+ target: "google_drive".into(),
+ ..source("src-drive", None)
+ });
+ assert_eq!(
+ apply_add(&mut config, &add_params("composio", "googledrive"))
+ .unwrap_err()
+ .code(),
+ INVALID_REQUEST
+ );
+ assert_eq!(config.memory.sources.len(), 2, "no duplicate was added");
}
#[test]