ABSTRACT Using agents to simulate human wayfinding processes helps to understand human decision-making and spatial cognition. The performance of large language models (LLMs) in agent-based wayfinding is still unclear. To address this, this study harnessed the thinking and reasoning capabilities of LLMs by designing an agent wayfinding framework based on cellular automata. This framework provides environmental descriptions in text form to the LLMs, enabling them to perceive the wayfinding environment and navigate within it. We simulated different spatial memory conditions for the LLM, including three types of spatial memories and one condition with no spatial memory, to observe its wayfinding behavior in a real-world setting. Multiple experiments were designed to compare the wayfinding performance of the LLM under different spatial memories, and 32 human participants conducted the same wayfinding experiments for reference. The results indicate that the LLM autonomously explores the environment and displays spatial reasoning abilities similar to humans. Furthermore, the LLM can develop reasonable wayfinding strategies to complete the tasks. This framework allows agents with different spatial memories to accurately reach their destinations. This research provides new ideas for utilizing large language models to construct more intelligent, efficient, and flexible wayfinding agents, which can help advance the application of agent technology in fields such as navigation and robotics.