Skip to content
项目

关于

AgentSociety 2 是一个现代化、原生支持 LLM 的智能体仿真平台,面向社会科学研究和实验设计。它提供了一个灵活的框架,用于在模拟环境中创建和管理智能体。

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
+11
15天
+23
1个月
+44

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README_zh.md

原文
AgentSociety Logo

AgentSociety: 社会中的 LLM 智能体

English · 中文

GitHub Stars License PyPI (v2) PyPI (v1)

Documentation v2 Documentation v1


AgentSociety 是面向 LLM 驱动智能体仿真与可执行社会科学研究的框架系列。研究者可以把研究问题、假设与干预转化为可运行的实验:AI Social Scientist 编排研究流程,Silicon Participants 则在仿真中生活。本仓库同时维护推荐使用的 AgentSociety 2 与旧版 AgentSociety 1.x。

论文:

机器可读引用:CITATION.cff · citations.bib

Star History

包结构

AgentSociety 2(推荐)

PyPI Version

AgentSociety 2 是 LLM 原生的一体化科研环境:AI Social Scientist 与 Silicon Participants 协作——科研技能覆盖从文献检索到数据分析的闭环,仿真则运行在可扩展的 Ray 运行时之上。

pip install agentsociety2

主要特性:

  • LLM 原生设计:从底层为 LLM 驱动智能体构建
  • 灵活的环境系统:模块化环境组件,支持热插拔工具
  • 多种推理模式:CodeGen(默认)、ReAct、Plan-Execute、Two-Tier 和 Search 路由器
  • 可扩展执行:智能体为 workspace 绑定的无状态 record,由 Ray Task 驱动,通过单一 ServiceProxy 注入 env / LLM clients / trace / replay 句柄
  • 科研技能:文献检索、假设生成、实验设计与数据分析(论文写作由外部 paper-toolkit 插件承担)
  • 实验回放:Catalog-driven JSONL 回放,DuckDB 读侧 + 分布式 trace
  • MCP 支持:Model Context Protocol 集成,扩展工具能力

架构 —— 从 AgentSociety 1 的社会仿真平台,到 AgentSociety 2 的双角色一体化科研环境:AI Social Scientist 负责实施实验并提供反馈,Silicon Participants 在仿真中生活(论文 图 2):

AgentSociety 2 双角色一体化科研环境

文档: agentsociety2.readthedocs.io

源码: packages/agentsociety2/

AgentSociety 1.x(旧版)

PyPI Version

AgentSociety 1.x 是原始的城市仿真框架,包含 gRPC 环境集成。

pip install agentsociety

主要特性:

  • 基于 Ray 分布式计算的城市级仿真
  • 城市场景模块(出行、经济、社交)
  • 多智能体协调与通信

文档: agentsociety.readthedocs.io

源码: packages/agentsociety/

其他包

工具

  • AI Social Scientist(extension/):AgentSociety 2 的 VS Code 科研工作台——基于工作区的对话式研究助手、实验配置与运行、回放、技能市场与 MCP 工具配置,详见使用指南。
  • frontend/:React Web 控制台。部分页面仍使用旧版接口;AgentSociety 2 的科研工作台由 VS Code 扩展提供。

仓库目录

AgentSociety/
├── packages/
│   ├── agentsociety2/      # v2.x,当前推荐包
│   │   └── examples/       # AS2 入门示例(basics / games / advanced)
│   ├── agentsociety/       # v1.x,旧版城市仿真
│   │   └── docs/           # v1 文档(legacy)
│   ├── agentsociety-community/
│   └── agentsociety-benchmark/
├── frontend/               # React Web 控制台
├── extension/              # AI Social Scientist VS Code 扩展(AS2 工作台)
└── examples/               # 示例实验(v1 经典实验 + v2/daily_mobility)

快速开始

AgentSociety 2

运行示例前请先配置 LLM 环境变量,例如:

export AGENTSOCIETY_LLM_API_KEY="your-api-key"
export AGENTSOCIETY_LLM_API_BASE="https://api.openai.com/v1"
export AGENTSOCIETY_LLM_MODEL="gpt-5.5"
import asyncio
from datetime import datetime
from pathlib import Path

from agentsociety2.contrib.env import SimpleSocialSpace
from agentsociety2.env import CodeGenRouter
from agentsociety2.society import AgentSociety


async def main():
    # 智能体以 spec 元数据声明;AgentSociety 在 init 时批量创建 workspace
    agent_specs = [{"id": 1, "profile": {"name": "Alice"}, "config": {}}]
    env = CodeGenRouter(
        env_modules=[SimpleSocialSpace(agent_id_name_pairs=[(1, "Alice")])]
    )
    society = AgentSociety(
        agent_specs=agent_specs,
        agent_class_name="PersonAgent",
        env_router=env,
        start_t=datetime.now(),
        run_dir=Path("run"),
    )
    await society.init()
    print(await society.ask("What's your name?"))
    await society.close()


asyncio.run(main())

AgentSociety 1.x

from agentsociety.simulation import AgentSociety

# 详见 packages/agentsociety/README.md

环境要求

  • Python 3.11.5 – 3.13
  • LLM API Key(OpenAI、Anthropic 或任意 litellm 支持的供应商)

贡献者

感谢所有为本项目做出贡献的人:

许可证

AgentSociety 采用 Apache License 2.0,packages/agentsociety/agentsociety/commercial 目录除外。详见 LICENSE。

引用

如果您在研究中使用了 AgentSociety,请按使用场景引用相应论文。使用当前平台(agentsociety2)时优先引用 AgentSociety 2;讨论原始大规模城市仿真器时引用 AgentSociety(v1)。

另见 CITATION.cff 与 citations.bib。

AgentSociety 2(arXiv:2607.11895):

@misc{piao2026agentsociety2,
  title        = {{AgentSociety} 2: An Integrated Research Environment for Executable Social Science},
  author       = {Jinghua Piao and Jun Zhang and Haoyu Huang and Keming Zhang and Jing Yi Wang and Xinran Zhao and Songwei Li and Boyuan Sun and Jiayi Chang and Fengli Xu and Chunyan Wang and Fang Zhang and Ke Rong and Jun Su and Tianguang Meng and Yi Liu and Qingguo Meng and Yu Wang and Yong Li},
  year         = {2026},
  eprint       = {2607.11895},
  archiveprefix= {arXiv},
  primaryclass = {cs.CY},
  doi          = {10.48550/arXiv.2607.11895},
  url          = {https://arxiv.org/abs/2607.11895},
}

AgentSociety(v1)(arXiv:2502.08691):

@misc{piao2025agentsociety,
  title        = {{AgentSociety}: Large-Scale Simulation of {LLM}-Driven Generative Agents Advances Understanding of Human Behaviors and Society},
  author       = {Jinghua Piao and Yuwei Yan and Jun Zhang and Nian Li and Junbo Yan and Xiaochong Lan and Zhihong Lu and Zhiheng Zheng and Jing Yi Wang and Di Zhou and Chen Gao and Fengli Xu and Fang Zhang and Ke Rong and Jun Su and Yong Li},
  year         = {2025},
  eprint       = {2502.08691},
  archiveprefix= {arXiv},
  primaryclass = {cs.SI},
  doi          = {10.48550/arXiv.2502.08691},
  url          = {https://arxiv.org/abs/2502.08691},
}

联系我们

探索相关项目

加载中…