Skip to main content

A Python library that lets you use LLM agents in economic experiments.

Project description

Python compat PyPi GHA Status Documentation Status


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:

  1. Agent Roles: Define player roles with customizable behaviors using a flexible prompt system.
  2. Game State: Hierarchical state management with automatic event-driven updates.
  3. Agent Managers: Manage agent connections to game servers and handle event processing.
  4. Game Runner: Orchestrates experiments by gluing together the other components.

Example Experiments

The repository includes three example games:

  1. prisoner: An iterated Prisoner's Dilemma game with 5 rounds and 2 LLM agents, runs on a local python server (included).
  2. dictator: A modified Dictator game with 2 LLM agents that runs on a local python server (included).
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

econagents-0.1.1.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

econagents-0.1.1-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file econagents-0.1.1.tar.gz.

File metadata

  • Download URL: econagents-0.1.1.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","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

Hashes for econagents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 df5abfb3cbe9f7fe01bb845f0eed0575d9fda7bda82a79b59a0adc9c04e0eb4f
MD5 d9d1ec24e02c8a98a34645b16a607e3f
BLAKE2b-256 35d5c863683e4d58429f16ef16d9951eab48151993777f51f034f18041ba41f3

See more details on using hashes here.

File details

Details for the file econagents-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: econagents-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","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

Hashes for econagents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 046d7dd82d4f5bab8a1fb530acdfd5f13d3adf2ff28c8befb11acde368f594cc
MD5 ee4fb5d8fd85937b3aebaeb550f489f9
BLAKE2b-256 21cedde7a9f1ad7dda5d682014819a9de3d1c837caf5ebad51e61ee1f7bb38b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page