Project Info
This project did not submit a demo video on Devpost.
A simulation platform for studying how collective behaviors emerge from AI agents.
Inspiration
Recent research has shown that LLM agents can be used as a new tool for social science research. Studies such as Fish et al. (2024) and Horton's Homo Silicus suggest that AI agents may help researchers explore economic and social behaviors at a scale that was previously impossible. Today, most AI-based social science tools follow a survey paradigm: agents are treated as respondents and researchers collect answers through prompts and questionnaires. We became interested in a different question: What happens when agents interact with each other through markets, institutions, and environments instead of simply answering questions? This inspired us to build MacroWeaver.
What it does
MacroWeaver is a simulation platform for studying how collective behaviors emerge from AI agents. Rather than treating agents as survey respondents or chatbots, MacroWeaver places them inside shared environments where they make decisions, interact through objective rules, and learn from feedback over time. The engine follows a simple loop: By changing only the underlying mechanism, the same engine can simulate markets, economies, and financial systems. This allows researchers to explore how phenomena such as collusion, inflation, and market dynamics can emerge from the interactions of many individual agents. Our goal is to build a reusable research infrastructure for the next generation of AI-powered social science.
How we built it
To solve this, we separated the simulation into reusable components: Agent profiles Private state Memory and reflection Decision policies Market mechanisms Scheduling Recording This allowed us to treat the market mechanism as a pluggable module while keeping the rest of the simulation pipeline unchanged. The result is a framework where very different research environments can be built on top of the same core engine rather than requiring entirely separate systems.
Challenges we ran into
The biggest challenge was finding a common abstraction across very different socio-economic simulations. At first glance, Fish, EconAgent, and financial market simulations appear to be completely different systems. They involve different agents, environments, market structures, and evaluation metrics. However, after studying these papers, we realized they share a common underlying pattern: The challenge was designing a framework flexible enough to support all of these settings without creating a custom implementation for every paper.
Accomplishments we're proud of
Successfully built a unified simulation framework capable of supporting multiple socio-economic environments. Demonstrated that the same agent architecture can be reused across very different research settings simply by swapping the underlying mechanism. Rather than building a single simulation, we built infrastructure that future simulations can be built upon.
What we learned
Building MacroWeaver taught us that the environment is often more important than the agent itself. Interesting social and economic phenomena do not come from individual intelligence alone — they emerge from repeated interactions, incentives, and feedback loops. Mechanism design provides a powerful way to study collective AI behavior beyond simple prompt engineering.
What's next
We plan to expand MacroWeaver into an open research platform for AI-assisted social science: Add more simulation environments Build a shared library of reusable mechanisms Support larger populations of agents Improve tools for visualization and analysis Our long-term goal is to provide a common infrastructure for studying how collective behaviors emerge in AI societies.
MacroWeaver
A generative socio-economic simulation engine with a web console. One fixed five-primitive kernel — Population·Agents → Mechanism(Market) → Observation → Scheduler → Recorder → write-back — where the Market is the only swappable block. Swap it and the same agents reproduce a different paper:
| Preset | Market | Result |
|---|---|---|
| Fish · Calvano (primary) | logit posted-price pricing | algorithmic collusion — price drifts from Bertrand‑Nash ≈1.47 toward monopoly ≈1.92 with no communication |
| EconAgent · Macro | labor + goods clearing | CPI / inflation / unemployment (Phillips) |
| TwinMarket · CLOB | limit order book | traded price vs. fair value with stylized facts (volatility clustering) |
Built from the component×paper generalization of four reference projects
(collusion-Fish2024, EconAgent, TwinMarket, and a prediction-market engine). The web
console implements the MacroWeaver.dc.html design (Landing → Presets → Console → Replay).
Architecture (React + Node + Python)
React console (web/) ──run──▶ Node BFF (server/) ──spawn──▶ Python engine (engine/)
Vite + Zustand REST /api + WS /ws five-primitive kernel
4-view SPA ◀── round-by-round NDJSON ───┘ swappable Market plugins
▲ │ writes
└────────── trace.json (replay scrub) ◀── /api/traces ◀────┘
- Python engine — the kernel
Runner(deterministicnp.random.SeedSequencesubstreams, event-sourced canonical JSON), aMarketABC with three plugins (fish_calvano,econagent,clob), the agent pipeline (Profile → Perception → Memory+Reflection → Decision), and two policies behind one interface:DeterministicPolicy(golden trace, no key) andClaudePolicy(live LLM via Anthropic tool-use). Streams NDJSON events per round and writes a self-containedtrace.json. - Node BFF — Express REST (
/api/presets|configs|traces|schema) + a WebSocket that spawnspython -m macroweaver stream, relays each round event to the browser, and indexes the finished trace. Python is the sole writer of traces. - React console — a 4-view SPA (Zustand store mirroring the design's state model): Landing, Presets, Console (concentric World view · Roster · Engine loop · cohort pipeline drawer · Metrics chart · Inspector with the Fish⇄EconAgent⇄CLOB market switch), and Replay (price-vs-benchmark chart + transport + per-agent reasoning cards).
Component × paper → module map
| Component | Fish | EconAgent | CLOB | Module |
|---|---|---|---|---|
| heterogeneous profile / private state | cost/quality · price hist | demographics · wealth | biases · holdings | agent/profile, CohortConfig |
| memory / reflection | notepad+insights | L-round pool · quarterly | BDI · BDI update | agent/memory, agent/reflection |
| decision / action | set price | work/consume [0,1] | place/hold order | policy/*, market.parse_decision |
| market mechanism | logit demand | labor+goods clearing | order-book matching | market/{fish_calvano,econagent,clob} |
| institution / production | – | tax+redistribution · rate · production fn | – | econagent params + LayerConfig |
| info/news · shock | rival prices | macro indicators · COVID-style | news+sentiment | market.news_text, market.apply_shock |
| scheduler · recorder · metrics | rounds · collusion index | quarters · inflation/Phillips | sessions · stylized facts | kernel/{scheduler,recorder}, metrics/* |
Quick start
# 1. engine (Python) — golden traces need no API key
cd engine && python3 -m venv .venv && ./.venv/bin/pip install -e '.[dev,llm]'
cd ..
# 2. server + web (Node workspaces)
npm install
# 3. run all three tiers (server :8787, vite :5173 with /api+/ws proxy)
npm run dev # then open http://127.0.0.1:5173
In the console: pick Fish · Calvano, press ▶ Run, watch the collusion curve form
live on the canvas, then scrub it in Replay with each agent's reasoning per round. Use
the Inspector's market switch to swap to EconAgent or CLOB, or flip a cohort to
Claude (live) (needs ANTHROPIC_API_KEY).
Engine CLI (no Node, no key)
make golden # deterministic Fish golden trace → traces/golden/fish_calvano.trace.json
make verify # assert byte-exact determinism
make test # pytest (golden reproducibility + market contracts)
make schema # export shared/config.schema.json
# any preset:
engine/.venv/bin/python -m macroweaver golden --config presets/econagent_macro.yaml \
--out traces/golden/econagent_macro.trace.json
Claude live mode
Set ANTHROPIC_API_KEY in engine/.env (see .env.example). Cohorts with
policy: claude then call Claude (claude-opus-4-8 by default) via forced tool-use for
schema-valid decisions, with an on-disk response cache, retry/backoff and refusal handling.
Without a key, claude cohorts fall back to the deterministic heuristic, so every demo
still runs and reproduces the curve. The deterministic golden trace is the reproducible,
zero-cost path used for the "golden trace" the design demos.
Layout
engine/macroweaver/ kernel/ (runner,config,events,sinks,scheduler,recorder,replay)
market/ (base ABC + fish_calvano, econagent, clob)
agent/ (pipeline, memory, reflection) policy/ (deterministic, claude)
metrics/ cli/
server/src/ index, routes, runManager (spawn+relay), files, config
web/src/ App, store; views/; console/{canvas,rail}; replay/; lib/chart
presets/ fish_calvano · econagent_macro · clob_twinmarket (+ golden traces)
shared/ config.schema.json (generated from pydantic)
Notes
- Determinism is the core invariant: a deterministic run is byte-exact reproducible
(
events.pycanonical JSON, ts masked) —make verifyand the test suite gate it. - The CLOB is a compact self-contained equity book (price-time priority, persistent book), not the binary-outcome prediction-market engine, so the action space is plain equity buy/sell/hold — a better fit for "financial market with stylized facts".
- EconAgent's macro calibration and CLOB's stylized facts are demo-grade; the mechanisms are real and pluggable. Optional layers (institution/social/news/shock) are wired as config-driven hooks; fiscal/monetary/production and shock injection are active, social propagation is a lightweight stub.
Analysis
View
Metric
- 18
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- AnthropicIn code
- CSSIn code
- ExpressIn code
- HTMLIn code
- JavaScriptIn code
- PythonIn code
- ReactIn code
- TypeScriptIn code
- Node.jsClaimed
8 of 9 appear in the indexed code. 1 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
- Claude CodeCommits
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
425 KB
Source files
82
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
siruizou2005/MacroWeaver
95 files · 21.6 MB · @ 5bdcc7b
Structure
Interface
6 files · 6%Screens, components and styles rendered to the user.
API & routing
6 files · 6%Request entry points: routes, handlers and controllers.
Application logic
64 files · 67%Domain rules, services and shared utilities.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- TypeScript60%
- Python31%
- JavaScript6%
- YAML2%
- Markdown2%
- CSS0%
- Other (1)0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
engine/pyproject.toml
pypi · 8- numpy
- pydantic
- pyyaml
- sortedcontainers
- typer
- +3 more
web/package.json
npm · 8- react
- react-dom
- zustand
- +5 more
server/package.json
npm · 3- express
- ws
- yaml
package.json
npm · 11 development-only dependencies.
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.