社会体系建模多Agent系统 (Social System Modeling Multi-Agent Framework)
简介
一个轻量级的多Agent协作框架,用于从基础假设推演出完整的社会体系模型。通过7个专业Agent(Systems/Econ/Socio/Governance/Culture/Risk/Validation)的协同分析,生成结构化、可验证的社会体系模型。
核心特性:
- 🔬 7个专业Agent: 覆盖系统思维、经济学、社会学、治理学、文化学、风险分析和验证
- 🔄 6步工作流: 假设验证→并行推演→冲突对齐→决策合成→证据校验→迭代收敛
- ⚡ 轻量级实现: TypeScript + Bun,可被Claude/AI直接调用
- 🛠️ MCP协议支持: 标准Model Context Protocol,可与Claude Desktop无缝集成
- 📊 结构化输出: 9层架构模型(总体结构/工作流/制度/治理/文化/创新/风险/指标/优化)
快速开始
安装
# 克隆项目
git clone <repository-url>
cd SocialGuessSkills
# 安装依赖
bun install
# 安装Biome
bun add -d biome
配置Biome
- 初始化Biome配置:
biome init
- 编辑生成的
biome.json文件以适配项目需求:
{
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {},
"style": {}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
- 运行Biome检查:
biome check
运行示例
# 运行端到端示例(社区治理模型)
bun run examples/run-example.ts
预期输出:
- 迭代次数: 2
- 置信度: 0.79
- Agent输出数量: 7(每个Agent都会生成分析)
- 冲突数量: 7(逻辑矛盾、优先级冲突、风险叠加)
运行配置(环境变量)
默认使用模拟输出,可通过环境变量切换真实 LLM 与失败策略:
LLM_PROVIDER:auto|anthropic|mock(默认auto)ANTHROPIC_API_KEY: 使用 Anthropic 时必填LLM_MODEL: 模型名称(默认claude-3-5-sonnet-20241022)LLM_MAX_TOKENS: 最大输出 token(默认4096)LLM_TIMEOUT_MS: LLM 超时毫秒数(默认60000)AGENT_MOCK_MODE: 强制 mock(true/false,默认false)FAIL_ON_CRITICAL: 关键 Agent 失败时中断流程(默认true)CRITICAL_AGENTS: 关键 Agent 列表(默认risk,governance,systems)
MCP集成(推荐)
在Claude Desktop中配置:
- 编辑
claude_desktop_config.json:
{
"mcpServers": {
"social-modeling": {
"command": "bun",
"args": ["run", "/absolute/path/to/src/server.ts"]
}
}
}
重启Claude Desktop
在Claude中使用:
请帮我分析:1000人社区,资源有限,如何建立稳定合作的社会体系?
Claude会自动调用MCP Server,生成完整的社会体系模型。
📖 详细集成指南: 查看 docs/MCP_INTEGRATION.md 了解:
- Claude Desktop完整配置步骤
- OpenCode CLI集成状态
- 故障排除指南
- 更多使用示例和Prompt模板
使用示例
1. 完整推演(reasoning tool)
输入:
{
"hypothesis": {
"assumptions": [
"1000人社区,资源有限(粮食、住房、工具)",
"协作可提升总产出30%",
"无外部干预,孤立环境"
],
"constraints": [
"通信成本:当面交流免费,间接传播有衰减",
"信息不完全:个体只知道邻近50人的状态"
],
"goals": [
"保证所有人基本生存(食物、住所)",
"建立可持续的资源生产与分配机制",
"冲突解决机制可执行"
]
},
"maxIterations": 3
}
输出: 完整的社会体系模型,包含:
- 7个Agent的分析(结论/依据/风险/建议/可证伪点)
- 检测到的冲突(类型/描述/严重性/解决方案)
- 9层结构化模型(总体结构/工作流/制度/治理/文化/创新/风险/指标/优化)
- 元数据(迭代次数/置信度/生成时间)
2. 单Agent查询(query_agent tool)
输入:
{
"agentType": "risk",
"hypothesis": {
"assumptions": ["资源稀缺", "有限理性"],
"constraints": [],
"goals": ["稳定秩序"]
}
}
输出: Risk Agent的专业分析,聚焦于脆弱性、极端情境和韧性策略。
3. 模型验证(validate_model tool)
输入:
{
"modelJson": "{...完整的模型JSON字符串...}"
}
输出: 验证结果,包含:
- isValid: 是否通过验证
- checks: 详细检查项(hasAllAgents, hasStructure, hasHypothesis等)
- issues: 发现的问题列表
- warnings: 警告信息(如冲突过多、置信度较低)
架构概览
┌─────────────────────────────────────────────────────┐
│ 用户输入假设 │
│ (assumptions/constraints/goals) │
└──────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ 1. 假设验证 (Systems Agent) │
│ - 检查结构完整性,识别关键变量 │
└──────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ 2. 并行Agent推演 (7个Agent) │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌───────┐ │
│ │Systems │ │ Econ │ │ Socio │ │Govern │ │
│ │ Agent │ │ Agent │ │ Agent │ │ Agent │ │
│ └────────┘ └────────┘ └────────┘ └───────┘ │
│ ┌────────┐ ┌────────┐ │
│ │Culture │ │ Risk │ │
│ │ Agent │ │ Agent │ │
│ └────────┘ └────────┘ │
└──────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ 3. 冲突对齐 (Risk Agent主导) │
│ - 检测逻辑矛盾、优先级冲突、风险叠加 │
│ - 标记需要重推的Agent │
└──────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ 4. 决策合成 (Governance Agent主导) │
│ - 应用决策合成规则:分层加权、冲突优先级 │
│ - 提取9层结构化模型 │
└──────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ 5. 证据校验 (Validation Ag
Tools 3
reasoningPerforms a full social system simulation based on provided assumptions, constraints, and goals.query_agentQueries a specific agent type for professional analysis on a given hypothesis.validate_modelValidates a structured social system model JSON for integrity and completeness.Environment Variables
LLM_PROVIDERLLM provider (auto, anthropic, or mock)ANTHROPIC_API_KEYrequiredAPI key for Anthropic modelsLLM_MODELModel name to use for analysis