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 agents to game servers, projects server events into typed game state, asks role-specific LLM policies for actions, and sends those actions back through protocol adapters.
Key Features
- Agent Runtime: Run one explicit
Agentper simulated player. - Ports and Adapters: Swap protocol codecs, transports, prompt renderers, response parsers, and state projectors.
- Flexible Agent Customization: Customize behavior with Jinja templates, response schemas, personas, or custom Python phase handlers.
- Event-Driven State Management: Project server events into typed public, private, and meta state.
- Turn-Based and Continuous Action Support: Handle one-shot phase decisions and repeated continuous-phase actions.
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 these main components:
- Domain Types:
Event,Action,PhaseId, andAgentContext. - Ports: Interfaces for codecs, transports, prompt rendering, response parsing, and state projection.
- Adapters: IBEX envelopes, WebSocket transport, Jinja prompts, JSON response parsing, and
EventFieldstate projection. - Roles: Role-specific LLM policies and phase participation rules.
- Agents: One runtime per simulated player.
- Game Runner: Supervises agents, logging, timeout, and cleanup.
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
uv run python examples/prisoner/server/server.py
# Run the experiment (in a separate terminal)
uv run python examples/prisoner/run_game.py
Note: set OPENAI_API_KEY before running OpenAI-backed examples.
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.2.2.tar.gz.
File metadata
- Download URL: econagents-0.2.2.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","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 |
7cf20f618f363da28f200817bc65eb75ab8451f34fe3e54b3b35da03ebf96cb6
|
|
| MD5 |
a18b5dff1718cd5efeeadb46c9f15ddf
|
|
| BLAKE2b-256 |
b8d085125393e9107ad49635e2045c808fde4cfbe6a8e4d9cf5d9c632cdd00da
|
File details
Details for the file econagents-0.2.2-py3-none-any.whl.
File metadata
- Download URL: econagents-0.2.2-py3-none-any.whl
- Upload date:
- Size: 63.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","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 |
c851d2a8e2082ec63218756805eb8805df48b7ff954d116a539e3a409fb579b4
|
|
| MD5 |
2cef9cffff49f9f2ae73d86c77800c69
|
|
| BLAKE2b-256 |
844f684a8ece1d8eda094ea167b1e827b456be5f544a37ab13d78898b1806bf3
|