Rabbi Yehoshua of Sikhnin said in the name of Rabbi Shmuel: He took counsel with the souls of the righteous. This is what is written: "These were the potters, and those who dwell among plantings and hedges; there they dwelt with the king in his work" (1 Chronicles 4:23). "These were the potters" (ha-yotzerim), on account of the verse: "And the LORD God formed (va-yitzer) the man, dust from the ground" (Genesis 2:7). "Those who dwell among plantings" (yoshvei netaim), on account of the verse: "And the LORD God planted (va-yita) a garden in Eden from the east" (Genesis 2:8). "And hedges" (gederah), on account of the verse: "Which I have placed as sand for a boundary (gevul) to the sea" (Jeremiah 5:22). "They dwelt with the king in his work": with the King, the King of kings of kings, the Holy One, blessed be He, dwelt the souls of the righteous, with whom the Holy One, blessed be He, took counsel and created the world.
The Council Of Souls
Bereshit Rabbah 8:7
רַבִּי יְהוֹשֻׁעַ דְּסִכְנִין בְּשֵׁם רַבִּי שְׁמוּאֵל אָמַר, בְּנַפְשׁוֹתָן שֶׁל צַדִּיקִים נִמְלָךְ, הֲדָא הוּא דִּכְתִיב: הֵמָּה הַיּוֹצְרִים וְישְׁבֵי נְטָעִים וּגְדֵרָה עִם הַמֶּלֶךְ בִּמְלַאכְתּוֹ יָשְׁבוּ שָׁם. הֵמָּה הַיּוֹצְרִים, עַל שֵׁם: וַיִּיצֶר ה' אֱלֹהִים אֶת הָאָדָם עָפָר מִן הָאֲדָמָה. יוֹשְׁבֵי נְטָעִים, עַל שֵׁם: וַיִּטַּע ה' אֱלֹהִים גַּן בְּעֵדֶן מִקֶּדֶם. וּגְּדֵרָה, עַל שֵׁם: אֲשֶׁר שַׂמְתִּי חוֹל גְּבוּל לַיָּם. עִם הַמֶּלֶךְ בִּמְלַאכְתּוֹ יָשְׁבוּ, עִם הַמֶּלֶךְ מֶלֶךְ מַלְכֵי הַמְלָכִים הַקָּדוֹשׁ בָּרוּךְ הוּא יָשְׁבוּ נְפָשׁוֹת שֶׁל צַדִּיקִים, שֶׁבָּהֶן נִמְלַךְ הַקָּדוֹשׁ בָּרוּךְ הוּא וּבָרָא אֶת הָעוֹלָם.