Abstract
Agent-based modeling (ABM) using Large Language Models (LLMs) offers a promising path toward simulating complex social phenomena. However, existing frameworks often suffer from "environmental poverty"—relying on simplistic rule sets—and a "scaling wall" that prevents simulations from reaching the size of real-world cities. We present AgentSociety, a scalable framework that integrates realistic urban, social, and economic environments with a parallelized interaction engine. By simulating up to 30,000 agents, we demonstrate that realistic environmental feedback is essential for generating authentic human-like behavior, achieving performance that exceeds real-time benchmarks.
Introduction
While LLMs excel at role-playing, their application in large-scale societal modeling has been hindered by two primary challenges. First, most current simulations occur in "toy" environments that lack the constraints of physical reality, such as commute times or financial management. Without these pressures, agent behaviors remain superficial. Second, simulating thousands of interacting agents introduces massive computational overhead and network bottlenecks, such as TCP port exhaustion.
AgentSociety addresses these issues by providing a high-fidelity environment and a robust engineering architecture capable of supporting the population of a small city.
The AgentSociety Framework
Realistic Societal Environments
The framework's core strength lies in its multi-dimensional feedback loop, which integrates three specialized spaces to provide realistic constraints to agents:
- Urban Space: Utilizing the MOSS toolkit and real-world data from OpenStreetMap and SafeGraph, this space simulates road networks and functional zones. A Golang-based simulator handles multi-modal movement (walking, driving, taxis) with high precision.
- Social Space: This layer models social networks and message passing, including a "supervisor" mechanism to simulate moderation and information propagation.
- Economic Space: Centered on an account-book simulator, this space tracks wages, consumption, taxes, and interest, providing macro-indicators like GDP through a simulated National Bureau of Statistics.
Parallelized Interaction Engine
To overcome the "scaling wall," AgentSociety employs a group-based parallel execution strategy. Agents are partitioned into groups assigned to Ray actors, allowing for efficient connection reuse and preventing system-level port exhaustion. A clock manager synchronizes the variable "thinking time" of LLMs with the fixed "physical time" of the environment, while asynchronous messaging via Redis Pub/Sub ensures non-blocking communication between agents.
Experimental Validation
The researchers validated the framework using mobility trajectories from 169 urban residents in Beijing as ground truth. The simulation utilized 24 NVIDIA A800 GPUs to support up to 30,000 agents.
Key Results
The experiments yielded several critical findings regarding scale and authenticity:
- Massive Scalability: The system successfully simulated 30,000 agents, with performance scaling linearly as computational resources increased.
- Efficiency: For a 30,000-agent population, a simulation round took approximately 251 seconds, maintaining a pace faster than real-time.
- Authenticity Boost: The inclusion of a realistic environment significantly improved the fidelity of agent behavior. Agents in the environment-aware setting (W-Env) exhibited movement patterns (measured by radius of gyration and daily location counts) much closer to real-world human data compared to those in text-only simulations (WO-Env).
Discussion and Conclusion
AgentSociety demonstrates that "the self" in an agent emerges through social and environmental experience. By providing agents with realistic constraints—such as choosing a bus over a taxi due to budget—the framework generates more convincing social phenomena.
While the current iteration focuses on message passing and basic economic tracking, future work will aim to integrate more complex social structures and dynamic market mechanisms. Furthermore, optimizing prompt engineering and request scheduling remains a priority to reduce the latency inherent in LLM API calls.
Summary updated