Skip to content

bug(memory): composio disconnect deletes memory chunks for all connections of the same toolkit #2598

@coderabbitai

Description

@coderabbitai

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

  1. Create two active Composio Gmail connections (connection A and connection B).
  2. Ingest memory from both connections — chunks are stored with source_id values like gmail:<id_A>:... and gmail:<id_B>:....
  3. Disconnect connection A with clear_memory: true.
  4. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions