Skip to main content

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 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 Agent per 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.
  • Hosted and Local Models: Use OpenAI or OpenRouter, or run local models through Ollama.

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:

  1. Domain Types: Event, Action, PhaseId, and AgentContext.
  2. Ports: Interfaces for codecs, transports, prompt rendering, response parsing, and state projection.
  3. Adapters: IBEX envelopes, WebSocket transport, Jinja prompts, JSON response parsing, and EventField state projection.
  4. Roles: Role-specific LLM policies and phase participation rules.
  5. Agents: One runtime per simulated player.
  6. Game Runner: Supervises agents, logging, timeout, and cleanup.

Example Experiments

The repository includes four 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).
  4. continuous_double_auction: A classical continuous double auction with LLM-backed traders using a continuous market phase.

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.

To route a YAML role through OpenRouter, set OPENROUTER_API_KEY and use an OpenRouter model slug:

roles:
  - role_id: 1
    name: "player"
    llm_type: "ChatOpenRouter"
    llm_params:
      model_name: "anthropic/claude-sonnet-4"

ChatOpenRouter supports structured outputs, tool calling, normalized reasoning controls, provider routing options, and optional app attribution.

Documentation

For detailed guides and API reference, visit the documentation.

You should also check out the econagents cookbook for more examples.

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.2.10.tar.gz (85.4 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.2.10-py3-none-any.whl (68.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: econagents-0.2.10.tar.gz
  • Upload date:
  • Size: 85.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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.2.10.tar.gz
Algorithm Hash digest
SHA256 e437577872326f9c0a2b50bffa540a1ea11546fe6be0bdec5037c14e89f7c000
MD5 076e02985a3e3e539c8a66d4e745d154
BLAKE2b-256 6b527e146835413632976c9ef7ec711c1aed72c2c59eb58f4fe7134d54beb3e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: econagents-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 68.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 74d394ae59189783e1adb18d96403072af33eb8ffa3aeee1789f4e8fe2dfe026
MD5 da0b9d5f0a5a6a6ed742416f1aae9cf7
BLAKE2b-256 6bda5258fb2f96914d5a8a0aeb5ed03409f1d39cbe4f54a10cc291f2dd720105

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 Sentry Error logging StatusPage Status page