fix(cli-node): keep every result in entity delete, not just the last#5970
Merged
kartik-mem0 merged 1 commit intoJun 29, 2026
Merged
Conversation
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
14 tasks
kartik-mem0
approved these changes
Jun 29, 2026
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 oneresultvariable that gets overwritten on the next pass, so only the last entity's response makes it back:mem0 entity deleteaccepts--user-id,--agent-id,--app-id, and--run-idtogether, and the entities command prints this value viaformatJson(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 thePromise<Record<string, unknown>>return type is unchanged.Type of Change
Breaking Changes
The JSON shape of
mem0 entity delete --output jsonchanges 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
Added
tests/platform-backend.test.tscovering multi-entity (fails without the fix), single-entity, and the no-entity error._requestis spied, so no network calls. Full vitest suite passes andtsc --noEmitis clean.Checklist