econagents is a Python library that lets you use LLM agents in economic experiments. The framework connects LLM agents to game servers through WebSockets and provides a flexible architecture for designing, customizing, and running economic simulations.
- Flexible Agent Customization: Customize agent behavior with Jinja templates or custom Python methods
- Persistent personality can be set: Built-in support to assign personalities to LLM players, example shown in Public goods game
- Event-Driven State Management: Automatically update game state based on server events
- Turn-Based and Continuous Action Support: Handle both turn-based games and continuous action phases
# Install from PyPI
pip install econagents
# Or install directly from GitHub
pip install git+https://github.com/IBEX-TUDelft/econagents.giteconagents consists of four key components:
- Agent Roles: Define player roles with customizable behaviors using a flexible prompt system.
- Game State: Hierarchical state management with automatic event-driven updates.
- Agent Managers: Manage agent connections to game servers and handle event processing.
- Game Runner: Orchestrates experiments by gluing together the other components.
The repository includes three example games:
prisoner: An iterated Prisoner's Dilemma game with 5 rounds and 2 LLM agents, runs on a local python server (included).dictator: A modified Dictator game with 2 LLM agents that runs on a local python server (included).public_goods: A public goods game with 4 players that runs on a local python server (included).
The simplest game to run is a version of the repeated prisoner's dilemma game that runs on your local machine.
# Run the server
python examples/prisoner/server/server.py
# Run the experiment (in a separate terminal)
python examples/prisoner/run_game.pyNote: you still have to set up the connection to the agents.
For detailed guides and API reference, visit the documentation.
You should also check out the econagents cookbook for more examples.
