Repository
agent-bazaar-implementation
Implementation of <a href="https://huggingface.co/papers/2605.17698">Agent Bazaar: Enabling Economic Alignment in Multi-Agent Marketplaces</a>, by Karten, Crow & Jin, in <a href="h · License unknown · Install via pip · Maintenance unknown
- License
- Unknown
- Provider
- Env var
- Anthropic
- ANTHROPIC_API_KEY
- GEMINI_API_KEY
Specs
- ProviderEnv var
- AnthropicANTHROPIC_API_KEY
- GoogleGEMINI_API_KEY
- OpenAIOPENAI_API_KEY
- KeyAction
- SPACEpause / resume
- ESCquit
README
Agent Bazaar
Implementation of <a href="https://huggingface.co/papers/2605.17698">Agent Bazaar: Enabling Economic Alignment in Multi-Agent Marketplaces</a>, by Karten, Crow & Jin, in <a href="https://github.com/kyegomez/swarms">Swarms</a> primitives.
The paper isolates two systemic failure modes that emerge when LLM agents run storefronts on behalf of humans, and shows that these failures are orthogonal to general reasoning capability — a more capable model is not necessarily more economically aligned. Two market-aligned harnesses (StabilizingFirm and SkepticalGuardian) are provided as drop-in policies that mitigate each failure mode.
A single number — the Economic Alignment Score (EAS, paper Eq. 5) — collapses four sub-scores (S_stab, S_integ, S_welf, S_prof) into a scalar in [0, 1], so 20+ models can be ranked on one chart.
We're hiring. swarms.ai is hiring multi-agent researchers to join our research team and work on multi-agent scaling laws — how collective behavior, coordination, and economic alignment scale with agent count, model size, and training compute. If problems like the ones in this repo are what you want to spend your days on, reach out at [email protected].
Install
git clone https://github.com/The-Swarm-Corporation/agent-bazaar-implementation
cd agent-bazaar-implementation
pip install -r requirements.txt
Environment variables
Swarms calls models through LiteLLM, which reads provider credentials from environment variables. Copy .env.example to .env and fill in the keys for the providers you plan to use.
$ cp .env.example .env
The paper evaluates three frontier models — set keys for whichever you want to drive:
| Provider | Env var | Paper model | LiteLLM string |
|---|---|---|---|
| Anthropic | ANTHROPIC_API_KEY |
Claude Sonnet 4.6 | claude-sonnet-4-6 |
GEMINI_API_KEY |
Gemini 3 Flash | gemini/gemini-3-flash |
|
| OpenAI | OPENAI_API_KEY |
GPT 5.4 | gpt-5.4 |
Defaults in agent_bazaar.py:
DEFAULT_MODEL = "claude-sonnet-4-6"— drives firms (Crash) and buyers (Lemon).DEFAULT_SELLER_MODEL = "gemini/gemini-3-flash"— pinned for Lemon sellers, matching the paper's "All sellers use Gemini 3 Flash" (§5.2).
So a minimal run of both needs both ANTHROPIC_API_KEY and GEMINI_API_KEY.
Usage
The default model is gpt-4.1. Swap any LiteLLM-compatible string with --model (e.g. claude-sonnet-4-6, gemini/gemini-2.5-pro, groq/llama-3.3-70b-versatile).
The Crash (B2C)
N firms compete for stochastic consumer demand under partial observability. Each firm sees a random dlc-sized sample of competitor prices and iteratively undercuts — the LLM-native analog of the 2010 Flash Crash.
# Watch the undercutting cascade
$ python agent_bazaar.py crash
# Insert the Stabilizing Firm harness on 3 of 5 firms
$ python agent_bazaar.py crash --stabilizers 3
# Provoke the crash failure mode (higher discovery limit, longer horizon)
$ python agent_bazaar.py crash --dlc-crash 5 --timesteps 30
The Lemon Market (C2C)
A single Deceptive Principal controls K coordinated seller identities, each with independent reputation. When a Sybil identity's reputation drops below ρ_min, the principal retires it and activates a fresh identity at the default reputation — Akerlof's market-for-lemons meets Douceur's Sybil attack.
# Lemon Market with 6 Sybil sellers, base buyers
$ python agent_bazaar.py lemon --sybils 6
# Insert the Skeptical Guardian harness on 4 of 12 buyers
$ python agent_bazaar.py lemon --sybils 6 --guardians 4
Both scenarios with EAS reports
$ python agent_bazaar.py both --model claude-sonnet-4-6
Visualization (Stardew-style sim)
A retro 2D pixel-art visualization of both scenarios lives in sim/. All sprites are generated programmatically — no external assets — and the package ships with a mock driver so the visual runs at game speed with no API keys. See sim/README.md for the full feature tour.
Sim install
pip install -r sim/requirements.txt
Run (mock mode, no API keys)
# B2C undercutting cascade — 5 produce stalls, 2 stabilizing firms
python -m sim.main crash --stabilizers 2
# C2C used-car bazaar — 8 sellers, 4 Sybils, 2 Skeptical Guardians
python -m sim.main lemon --sellers 8 --sybils 4 --guardians 2
Run with real LLM agents
python -m sim.main crash --live --model claude-sonnet-4-6
python -m sim.main lemon --live --sybils 4 --guardians 2
--live drives real swarms.Agent instances from agent_bazaar.py in a background thread; the in-game day advances when the LLM step returns. Sprites animate freely in between.
Controls
| Key | Action |
|---|---|
SPACE |
pause / resume |
ESC |
quit |
What you see
- Crash: striped market stalls along a cobblestone plaza, each firm selling its own produce (apples, fish, bread, cheese, carrots, eggs, mushrooms, pumpkins). Inventory is piled on the counter and shrinks as customers buy. Price tags turn red when the firm prices below unit cost. Bankrupt stalls get boarded up with a
CLOSEDsign. - Lemon: a grid of used cars. Each car's appearance reflects the claimed tier (shiny + sparkles for "mint", rust spots for "poor"), so Sybil sellers look mint-shiny until their reputation drops below 0.5 — at which point the sprite flips to the true tier and a red
!! deceptivetag appears. Guardian buyers have a green halo. - Speech bubbles: every tick, two agents speak. In mock mode they show plausible per-role reasoning (
"Cheapest rival $1.04. Undercut to $0.91."); in--livemode they show the actualreasoningfield from the agent's JSON response. Guardian bubbles have a green border; exposed Sybils get a red one. - HUD: live EAS gauge, all four sub-score bars, day counter, scrolling event ticker (bankruptcies, Sybil retirements).
Programmatic use
from agent_bazaar import (
CrashConfig, run_crash, crash_components,
LemonConfig, run_lemon, lemon_components,
eas,
)
# The Crash
cfg = CrashConfig(num_firms=5, num_stabilizers=3, timesteps=15)
telem = run_crash(cfg)
print("EAS:", eas(crash_components(telem, cfg)))
# The Lemon Market
cfg = LemonConfig(num_sellers=12, sybil_cluster=6, num_guardians=4, timesteps=8)
telem = run_lemon(cfg)
print("EAS:", eas(lemon_components(telem)))
What is not implemented
The paper trains a 9B model with REINFORCE++ + LoRA on a curriculum of market difficulties (§4.2 / §5.3). That training loop is out of scope for a Swarms-primitives port — the harnesses are present, the trained AI Bazaar model is not. To reproduce trained-agent results you would need the paper's training pipeline plus a reward function built on top of crash_components / lemon_components.
Citation
@article{karten2026agentbazaar,
title = {Agent Bazaar: Enabling Economic Alignment in Multi-Agent Marketplaces},
author = {Karten, Seth and Crow, Drew and Jin, Chi},
journal = {arXiv preprint arXiv:2605.17698},
year = {2026},
url = {https://huggingface.co/papers/2605.17698}
}
@misc{gomez2024swarms,
title = {Swarms: The Enterprise-Grade Production-Ready Multi-Agent Framework},
author = {Gomez, Kye},
year = {2024},
url = {https://github.com/kyegomez/swarms}
}