Skip to content

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

Description

@abhay-codes07

Component

Other (@mem0/cli — Node/TypeScript CLI)

Description

This is the TypeScript CLI counterpart of #5935 (fixed for the Python CLI in #5936).

PlatformBackend.deleteEntities() in cli/node/src/backend/platform.ts loops over every entity but reassigns a single result variable each pass, so it returns only the last entity's API response:

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

mem0 entity delete accepts --user-id, --agent-id, --app-id, and --run-id together, and cmd_entities_delete prints this value verbatim via formatJson(result) under --output json (cli/node/src/commands/entities.ts). So a multi-entity delete silently drops every response except the last.

Steps to Reproduce

mem0 entity delete --user-id alice --agent-id bob --force --output json
# JSON shows only the agent deletion; the user deletion response is gone.

Expected Behavior

All deletion responses are returned, keyed by entity type, matching the Python fix in #5936:

{ "user": { ... }, "agent": { ... } }

Actual Behavior

Only the final entity's response is returned; earlier ones are overwritten and lost.

Environment

  • @mem0/cli: current main
  • Node: 20
  • OS: platform-independent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions