Arena is the integration layer that connects the three core Social Arena packages into a single, configurable simulation:
- Agent: AI agents with 9 fundamental social actions (
agentpackage) - Feed: Twitter-style Pydantic data models (
feedpackage) - Recommendation: Centralized recommendation system (
recommendationpackage, Twitter-style algorithm)
(see the Recommendation README for details:https://github.com/Social-Arena/Recommendation).
Arena is built directly from the example in external/Agent/examples/simple_simulation.py,
but upgraded to:
- Use the real
CentralizedRecommendationSystem+BalancedStrategy - Use
feed.FeedPydantic models throughout the feed pool - Provide a configurable, reusable Python API
pip install "arena @ git+https://github.com/Social-Arena/Arena.git@dev"This will also install the dev branches of:
agent @ git+https://github.com/Social-Arena/Agent.git@devfeed @ git+https://github.com/Social-Arena/Feed.git@devrecommendation @ git+https://github.com/Social-Arena/Recommendation.git@dev
If you are working from this repository with submodules checked out:
# Clone the repository
git clone https://github.com/Social-Arena/Arena.git
cd Arena
# Initialize and update submodules
git submodule update --init --recursive
# Checkout dev branch for each submodule
cd external/Feed && git checkout dev && cd ../..
cd external/Recommendation && git checkout dev && cd ../..
cd external/Agent && git checkout dev && cd ../..
# Set up virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies from local submodules (dev branches)
pip install -e external/Feed
pip install -e external/Recommendation
pip install -e external/Agent
# Install Arena itself
pip install -e .Create a .env file in the Arena root directory:
# Copy the template from Agent submodule
cp external/Agent/env.template .env
# Edit .env and add your API key
# OPENAI_API_KEY=your_actual_openai_key_here
# or
# ANTHROPIC_API_KEY=your_actual_anthropic_key_hereIn one terminal, start the agent LLM host:
source venv/bin/activate
# Load .env and start OpenAI host
export $(cat .env | grep -v '^#' | xargs)
python -m agent --provider openai --port 8000
# Or for Anthropic/Claude:
# python -m agent --provider anthropic --port 8000source venv/bin/activate
python arena.py -n_of_agents 10 -post_per_day 5 -days_of_simulations 5CLI Arguments:
-n_of_agents: Number of agents to create (default: 10)-post_per_day: Posts each agent creates per day (default: 5)-days_of_simulations: Number of days to simulate (default: 5)-fetch_per_day: Posts each agent fetches from recommendation system per day (default: 10)-explore_ratio: Exploration ratio for recommendations (default: 0.2)-output: Output directory (default:cache/arena_output_TIMESTAMP)
Output Structure:
cache/arena_output_20241201_123456/
├── agents/ # Individual agent cache files per day
│ ├── agent_000_day000.json # Initial state
│ ├── agent_000_day001.json # After day 1
│ ├── agent_000_day002.json # After day 2
│ └── ...
├── feeds/ # All feeds created during simulation
│ └── all_feeds.json
└── recommendation/ # Recommendation mappings and state
├── agent_000_day001_mapping.json # What feeds were recommended to each agent
├── agent_001_day001_mapping.json
└── recommendation_state.json # Final recommendation system state
What happens during simulation:
Each day:
- Morning: Each agent creates
post_per_dayposts → ingested into recommendation system - Afternoon: Each agent fetches
fetch_per_dayposts from recommendation system - Decision: LLM decides what action to take (like, reply, follow, idle)
- Action: Agent executes the action and updates state
- Evening: Agent states saved to
agents/folder
After all days:
- All feeds saved to
feeds/all_feeds.json - Recommendation mappings show which feeds were sent to which agents
- Final recommendation system state saved
Example: With 10 agents, 5 posts/day, 5 days:
- Agents folder: 10 agents × 6 states (initial + 5 days) = 60 JSON files
- Feeds folder: 10 agents × 5 posts/day × 5 days = 250+ feeds (plus replies)
- Recommendation folder: Daily mappings + final state
┌───────────────────────────────────────────┐
│ ArenaSimulationCLI │
│ (Orchestrates Agent + Feed + RecSys) │
└───────────────┬──────────────────────────┘
│
┌─────────▼─────────┐
│ CentralizedRecommendationSystem │ recommendation
│ + BalancedStrategy │
└─────────┬─────────┘
│
┌─────────▼─────────┐
│ N Agents │ agent.Agent (Pydantic)
└─────────┬─────────┘
│
┌─────────▼─────────┐
│ Feeds (Pydantic) │ feed.Feed
└────────────────────┘
For the underlying recommendation algorithm details, see the
Recommendation repository README: https://github.com/Social-Arena/Recommendation.