A Python library that lets you use LLM agents in economic experiments.
Project description
econagents
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.
Key Features
- 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
Installation
# Install from PyPI
pip install econagents
# Or install directly from GitHub
pip install git+https://github.com/IBEX-TUDelft/econagents.git
Framework Components
econagents 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.
Example Experiments
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).
Running the Prisoner's Dilemma game
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.py
Note: you still have to set up the connection to the agents.
Documentation
For detailed guides and API reference, visit the documentation.
You should also check out the econagents cookbook for more examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file econagents-0.0.11.tar.gz.
File metadata
- Download URL: econagents-0.0.11.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6605a2aef1112e704194a2e9347ce154119b6457ffc3563eff33c478fbc8e9b
|
|
| MD5 |
ff3728508902e3ffddf1bab051a9ba54
|
|
| BLAKE2b-256 |
79f3f46df6d338c5cff4607e8d9b25a40a0ac0dec9dd4c6f8012394afcf6f0f9
|
File details
Details for the file econagents-0.0.11-py3-none-any.whl.
File metadata
- Download URL: econagents-0.0.11-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b2a9462975cd4bd40a453fae01f14fb803343a6806acc4571e49477559ddb0
|
|
| MD5 |
6f89757df3fb4f1744836234f52237f8
|
|
| BLAKE2b-256 |
b134d8f2a518e377347bbfd69f11d2909a2549687f40d1248db8f561efad7f3c
|