mem0ai/mem0 · error · Error

Either memoryId or --all is required

Error message

Either memoryId or --all is required

What it means

Thrown by PlatformBackend.delete when neither a specific memoryId nor the --all/opts.all flag was supplied. The DELETE path needs either a single target (/v1/memories/{id}/) or filter parameters for a bulk delete (/v1/memories/?user_id=...), so the call is rejected before any network request is made.

Source

Thrown at integrations/openclaw/backend/platform.ts:263

    opts: DeleteOptions = {},
  ): Promise<Record<string, unknown>> {
    if (opts.all) {
      const params: Record<string, string> = {};
      if (opts.userId) params.user_id = opts.userId;
      if (opts.agentId) params.agent_id = opts.agentId;
      if (opts.appId) params.app_id = opts.appId;
      if (opts.runId) params.run_id = opts.runId;
      return (await this._request("DELETE", "/v1/memories/", {
        params,
      })) as Record<string, unknown>;
    }
    if (memoryId) {
      return (await this._request(
        "DELETE",
        `/v1/memories/${memoryId}/`,
      )) as Record<string, unknown>;
    }
    throw new Error("Either memoryId or --all is required");
  }

  async deleteEntities(opts: EntityIds): Promise<Record<string, unknown>> {
    // v2 endpoint: DELETE /v2/entities/{entity_type}/{entity_id}/
    const typeMap: [string, string | undefined][] = [
      ["user", opts.userId],
      ["agent", opts.agentId],
      ["app", opts.appId],
      ["run", opts.runId],
    ];
    const entities = typeMap.filter(([, v]) => v) as [string, string][];
    if (entities.length === 0) {
      throw new Error("At least one entity ID is required for deleteEntities.");
    }
    // Delete each provided entity via the v2 path-based endpoint
    let result: Record<string, unknown> = {};
    for (const [entityType, entityId] of entities) {
      result = (await this._request(

View on GitHub (pinned to 001c235229)

Solutions

  1. Pass a concrete memory id: backend.delete('m-uuid').
  2. Or opt into bulk delete explicitly: backend.delete(undefined, { all: true, userId }) — note bulk delete requires filter params (user_id/app_id/run_id) on the platform endpoint.
  3. If scripting, guard the call: skip deletion when the id is empty instead of calling delete().

Example fix

// before
await backend.delete(memoryId); // memoryId is undefined

// after
if (!memoryId && !opts.all) {
  throw new Error('refusing to delete: no memoryId and no --all');
}
await memoryId
  ? backend.delete(memoryId)
  : backend.delete(undefined, { all: true, userId });
Defensive patterns

Strategy: validation

Validate before calling

function assertDeleteArgs(memoryId?: string, opts: { all?: boolean } = {}) {
  if (!memoryId && !opts.all) {
    throw new Error('refusing to call delete: pass a memoryId or { all: true }');
  }
}

Try / catch

try {
  await backend.delete(memoryId, opts);
} catch (err) {
  if (err instanceof Error && err.message === 'Either memoryId or --all is required') {
    // resolve an id via search() or re-run with { all: true }
  } else throw err;
}

Prevention

When it happens

Trigger: Calling backend.delete(undefined) or backend.delete() with opts.all unset; a CLI delete command invoked with no arguments and no --all flag; passing an empty-string memoryId (falsy) together with opts.all missing.

Common situations: CLI usage mistake (mem0 memory delete with no args); scripted deletion where the memoryId variable is undefined because an earlier search returned no results; agent tool invocation that omitted the id parameter.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/9a36200662535902. Report an issue: GitHub.