Summary
When a user disconnects a Composio integration, composio_toolkit_source_kind in src/openhuman/composio/ops.rs maps the toolkit slug to a broad LIKE prefix (e.g. gmail:%, notion:%). The subsequent delete_chunks_by_source call then deletes all memory chunks whose source_id matches that prefix — not just chunks belonging to the specific connection being disconnected.
This means that in multi-connection scenarios (e.g. a user with two active Gmail connections), disconnecting one connection will silently wipe memory chunks indexed under the other connection(s) for the same toolkit.
Steps to Reproduce
- Create two active Composio Gmail connections (connection A and connection B).
- Ingest memory from both connections — chunks are stored with
source_id values like gmail:<id_A>:... and gmail:<id_B>:....
- Disconnect connection A with
clear_memory: true.
- Observe that chunks belonging to connection B are also deleted because the LIKE pattern
gmail:% matches both.
Expected Behaviour
Only memory chunks scoped to the specific connection_id being disconnected should be deleted.
Suggested Fix
Derive the source_id_pattern from the concrete connection_id (e.g. gmail:<connection_id>:%) rather than from the toolkit slug alone. This requires understanding how source_id values are structured per-connection vs. per-toolkit in the memory tree.
Context
Deferred from PR #2546 (feat: opt-in memory deletion on channel / composio disconnect) — #2546
Flagged by @coderabbitai during review, deferred by @senamakel for a follow-up.
Summary
When a user disconnects a Composio integration,
composio_toolkit_source_kindinsrc/openhuman/composio/ops.rsmaps the toolkit slug to a broad LIKE prefix (e.g.gmail:%,notion:%). The subsequentdelete_chunks_by_sourcecall then deletes all memory chunks whosesource_idmatches that prefix — not just chunks belonging to the specific connection being disconnected.This means that in multi-connection scenarios (e.g. a user with two active Gmail connections), disconnecting one connection will silently wipe memory chunks indexed under the other connection(s) for the same toolkit.
Steps to Reproduce
source_idvalues likegmail:<id_A>:...andgmail:<id_B>:....clear_memory: true.gmail:%matches both.Expected Behaviour
Only memory chunks scoped to the specific
connection_idbeing disconnected should be deleted.Suggested Fix
Derive the
source_id_patternfrom the concreteconnection_id(e.g.gmail:<connection_id>:%) rather than from the toolkit slug alone. This requires understanding howsource_idvalues are structured per-connection vs. per-toolkit in the memory tree.Context
Deferred from PR #2546 (feat: opt-in memory deletion on channel / composio disconnect) — #2546
Flagged by @coderabbitai during review, deferred by @senamakel for a follow-up.