Robert Chisholm’s article "ANATOMY OF AN ANTHROPOMORPHISM: DOES GOD DISCOVER FACTS?" explains OT texts like Genesis 18:20-21 and 22:12, which seem to indicate God does not know everything. Chisholm is not satisfied with saying they are antropromorphic and leaving it at that; he seeks a full understanding of why the passages, on the surface, indicate God is learning something.
According to Chisholm “when God speaks within a metaphorical framework, His words may veil certain aspects of the divine nature, but they have a specific function to perform that contributes powerfully to His purpose) in the world of the narrative.” Chisholm continues “the literary context of each passage provides the key to understanding why God did this. In each case God's anthropomorphic self-revelation occurs within a metaphorical framework that is inherently relational in nature. God assumes a relational role and then speaks in a way that is consistent with it. Through His anthropomorphic self-revelation God made it clear that His relationship with Abraham was personal and dynamic. The metaphor boldly fleshes out the underlying reality. By revealing Himself in this way God also emphasized the importance of human responsibility. Human decisions would play a formative role in how the future of Abraham and his world would unfold. God grants human beings, whom He has made in (or as) His image, the dignity of causality. His plan for human history accommodates human decisions and actions, as well as His own responses to them.”
Regarding Genesis 18, Chisholm comments, “the context depicts the Lord in the role of cosmic judge. When Abraham heard the Lord speak of the moral condition of Sodom and Gomorrah, Abraham interceded on behalf of the cities because of his concern for the well-being of Lot and his family. He asked rhetorically, "Will not the judge of the whole earth do what is right?" (v. 25).17 Judges, at least those committed to justice, typically get the facts straight before they issue a ruling and execute justice.”
Chisholm continues, “the Lord considered it appropriate to share His intentions with Abraham (v. 17), which suggests that the language was dynamic and motivational. Perhaps the Lord wanted to prepare Abraham emotionally to accept predetermined divine judgment. The angels' words to Lot in 19:13-14 may imply this was the case, but they do not necessarily carry such an implication.19 If judgment was not a foregone conclusion (at least from a historical perspective) before the angels' arrival, then it is possible the Lord's words in 18:20-21 were designed to motivate Abraham to assume the role of intercessor and to prompt the response they elicited.”
Regarding Genesis 22, Chisholm comments, “when God chose Abraham to be His covenant partner, the arrangement was comparable to the suzerain-vassal treaty relationship attested in the ancient Near East. The story reaches its climax when Abraham demonstrated his loyalty (22:12, 15-18) by obeying God's command (cf. 26:5). God then elevated the patriarch to the status of a favored vassal who now possessed a ratified promise, comparable to the royal grants attested in the ancient Near East. God contextualized His self-revelation to Abraham (and to the readers of the narrative) within the relational, metaphorical framework of a covenant lord. Thus one should not be surprised to hear Him speak in ways that reflect the relational role He assumed within this metaphorical framework.”
Chisholm points out “Open theists sometimes appeal to Genesis 22:12 in support of their position, but, as pointed out, this verse, like 18:21, pertains to God's present, not future, knowledge. Presumably open theists explain this language of uncertainty and discovery in 18:21 as anthropomorphic. But the same hermeneutical model one utilizes to explain how anthropomorphism works in 18:21 can be applied to texts that seemingly limit God's knowledge of the future.”