Skip to content

fix(cli-node): keep every result in entity delete, not just the last#5970

Merged
kartik-mem0 merged 1 commit into
mem0ai:mainfrom
abhay-codes07:fix/cli-node-delete-entities-partial-result
Jun 29, 2026
Merged

fix(cli-node): keep every result in entity delete, not just the last#5970
kartik-mem0 merged 1 commit into
mem0ai:mainfrom
abhay-codes07:fix/cli-node-delete-entities-partial-result

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #5969

Description

TypeScript CLI counterpart of #5936 (Python). deleteEntities() walks every entity it's asked to delete, but writes each API response into one result variable that gets overwritten on the next pass, so only the last entity's response makes it back:

let result: Record<string, unknown> = {};
for (const [entityType, entityId] of entities) {
    result = (await this._request("DELETE", `/v2/entities/${entityType}/${entityId}/`, ...));
}
return result;

mem0 entity delete accepts --user-id, --agent-id, --app-id, and --run-id together, and the entities command prints this value via formatJson(result) under --output json. Delete two entities and the JSON only shows one.

The fix collects each response into a record keyed by entity type ({ user: {...}, agent: {...} }), matching the Python fix. Nothing is dropped, the deletes always happened (one request each), and the Promise<Record<string, unknown>> return type is unchanged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (no functional changes)
  • Documentation update

Breaking Changes

The JSON shape of mem0 entity delete --output json changes from a single raw API response to a map keyed by entity type, only in the multi-entity case (which was lossy before). Human and agent output modes are unaffected. Kept consistent with the Python fix in #5936.

Test Coverage

  • I added/updated unit tests
  • I added/updated integration tests
  • I tested manually (describe below)
  • No tests needed

Added tests/platform-backend.test.ts covering multi-entity (fails without the fix), single-entity, and the no-entity error. _request is spied, so no network calls. Full vitest suite passes and tsc --noEmit is clean.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix works
  • New and existing tests pass locally
  • I have updated documentation if needed (no user-facing docs affected)

deleteEntities looped over each entity but reassigned a single `result`
variable, so a multi-entity delete (e.g. --user-id and --agent-id together)
returned only the last entity's response. Under `mem0 entity delete
--output json` the other deletions were silently dropped.

Collect responses into a record keyed by entity type. No data is lost and the
Promise<Record<string, unknown>> return type is preserved. This mirrors the
Python CLI fix in mem0ai#5936.

Adds a backend test covering multi-entity, single-entity, and the no-entity
error; the multi-entity case fails without the fix.

Closes mem0ai#5969
Copilot AI review requested due to automatic review settings June 29, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kartik-mem0
kartik-mem0 merged commit 31cec11 into mem0ai:main Jun 29, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cli-node): entity delete returns only the last entity's response (TS counterpart of #5935)

3 participants