Skip to content

Repository files navigation

Baymax

A market for medical supplies, run by hospital AI agents. Each hospital gets its own autonomous agent that watches inventory, forecasts demand, and negotiates, buys, sells, and orders critical supplies with other hospitals, before anyone runs out.

Best Use of Fetch.ai Agentverse Devpost AI Hackathon Live demo

▶ Try the live demo: a self-contained walkthrough of the dashboard and the Supply Exchange. No install, no backend, no keys.


The idea

Polymarket predicts elections. Kalshi makes the future tradable.

So we asked a slightly uncomfortable question:

What if hospitals had their own prediction market for medical supplies during crises?

That became Baymax: an AI agent swarm that gives each hospital its own autonomous agent. Each agent can monitor inventory, reason about future demand, negotiate with other hospital agents, buy and sell medical supplies, and order from third-party suppliers when no nearby hospital can fulfill the request.

It sounds dystopian. But during wildfires, heatwaves, or sudden patient surges, one hospital may run critically short on an item while another hospital a few miles away has extra sitting in storage. That is not always a supply problem. Sometimes it is a coordination problem, and coordination problems are what markets and agents are good at.

The bigger question we explored: if markets can help predict elections, inflation, and global events, can autonomous agents use market mechanisms to allocate critical resources faster?

Baymax is not about making hospitals trade like Wall Street. It is coordination infrastructure for the moments where speed actually matters.

Scope & safety. Baymax handles operational logistics only: what to move, how much, by when. Never clinical guidance. All settlement is testnet-scoped by construction; mainnet is refused and no real funds are ever routed.


What it does

Baymax runs one agent per hospital. Each agent knows its live stock and its forecast demand, and it can act on both. The end-to-end loop:

  1. Sense. Each agent reads live inventory (shelf camera → Claude Vision) and pulls crisis signals from real external feeds: weather, air quality, severe-weather alerts, earthquakes, WHO outbreaks, CDC respiratory levels, and local news.
  2. Forecast. Claude synthesizes those signals into a per-hospital risk read: which items are exposed, why, and how urgently.
  3. Detect. When falling stock converges with rising forecast demand, the agent flags a shortfall and scopes the need.
  4. Negotiate. The requesting agent broadcasts the need; every surplus hospital's agent independently decides what it can spare (each is its own Claude call, reasoning about its own safety reserve). Claude then ranks the offers and composes a transfer, splitting across facilities when no single one can cover the need.
  5. Settle. With approval, the transfer settles on the Fetch.ai testnet, priced off the live Supply Exchange mark. Every leg lands on a shared trades tape.
  6. Escalate. If no nearby hospital can fulfill the request, the agent orders directly from a third-party supplier by driving a real vendor site in a cloud browser.

Every step narrates itself back into the dashboard in real time.


The Supply Exchange

The centerpiece. Baymax runs a continuous market for six critical supplies: the "prediction market for hospital supplies" made real. The price two hospital agents settle on is the demand signal.

Symbol Supply Base price (testnet FET / unit)
VENT Ventilators 1000
O2 Oxygen 200
SALINE Saline 50
IV_FLUIDS IV fluids 30
N95 N95 masks 5
SUTURES Sutures 15

How the market works:

  • A live market maker re-prices every symbol each tick off real Redis state: surplus on hand, forecast demand, and crisis risk:

    price = base × (1 + K · signal) × scarcity
    signal   = clamp(0.6 · crisis_risk + 0.4 · demand/demand_ref, 0, 1)
    scarcity = clamp(demand / total_surplus, 1, cap)
    

    A critical crisis plus a demand spike plus drained surplus drives a symbol from its baseline toward a 5× scarcity ceiling.

  • A real limit order book with price-time-priority matching: resting bids and asks cross and execute at the maker's price.

  • A velocity circuit breaker. Any symbol that moves ≥ 25% within a 10-second window is halted (30-second auto-resume, or clear it manually), and the dashboard shows a red halt banner. Trading pauses exactly when a market gets disorderly, the moment a crisis is actually spiking.

  • One shared fills feed. Negotiated inter-hospital transfers and order-book trades write to the same tape, so the dashboard and the exchange never disagree on a trade or its price. The FET price a settlement pays is the price the tape displays.

Open /exchange in the live demo to watch it tick, halt, and settle.


Architecture

The live stack is one command (./scripts/start_demo.sh):

Next.js web (:3000)
     │
     ▼
Flask bridge  apps/api/app.py (:5001) ───▶ Redis (:6379)
     │                                        ▲   ▲
     ├──▶ Claude engine  run_claude_demo.py ──┘   │  (state + pub/sub bus)
     │        (per-hospital negotiation)          │
     └──▶ Exchange market maker  exchange.pricing ┘  (prices → baymax:ticker)

Everything communicates through a Redis seam: inventory, surplus, forecasts, crisis state, the transfers stream, exchange prices, and live event channels (baymax:crisis, baymax:trigger, baymax:decision, baymax:narration, baymax:ticker, baymax:fills). That seam is what let vision, forecasting, negotiation, the exchange, and the dashboard all be built in parallel without coupling, each with a deterministic fail-closed fallback so the demo never hangs.

Two generations of the swarm, both in this repo:

  • The award-winning build ran as a Fetch.ai uAgents swarm on Agentverse, reachable through ASI:One with the Chat and Payment protocols, settling real on-chain testnet FET (RequestPayment → CommitPayment → CompletePayment). It's preserved intact in archive/uagents/ for reference.
  • The current engine runs the same negotiation as a Claude-native asyncio swarm (backend/engine/): no Bureau, no message bus, just concurrent Claude agents coordinating through Redis. Faster to run, self-contained, and the path the live demo uses. Settlement is priced off the live exchange mark and runs a deterministic testnet settlement by default (so the demo never blocks), with a real on-chain cosmpy transfer on the Fetch stable testnet available behind an env flag (testnet only, never mainnet).

The negotiation contracts live behind clean seams in backend/engine/interfaces.py, each with a live backend (behind a BAYMAX_* flag) and a deterministic mock:

Seam Live backend Falls back to
get_inventory Redis (+ Claude Vision shelf count) mock inventory
research_crisis Claude keyword risk profiles
ingest_forecast WHO / CDC / weather signals mock forecast
rank_offers Claude nearest-first greedy allocator
order_from_supplier Browserbase + Stagehand vendor automation mock vendors

Built with

Layer What we used
Agent swarm & settlement Fetch.ai Agentverse / uAgents (award-winning build; ASI:One + Chat & Payment protocols, on-chain testnet FET) → evolved to a Claude-native asyncio swarm settling on Fetch testnet FET
Reasoning Claude (Opus + Sonnet) via the Anthropic API: crisis research, offer ranking, and each hospital's independent spare-capacity decision. Entire codebase built with Claude Code.
Vision Claude Vision counts real stock on a physical shelf (a green-straw divider splits Hospital A from Hospital B) and writes straight to Redis
State & pub/sub Redis: inventory, surplus, forecasts, transfer audit stream, exchange prices, and live event channels
Crisis signals Open-Meteo (weather + air quality), NWS alerts, USGS quakes, WHO Disease Outbreak News, CDC NSSP respiratory levels, Claude web search, and Browserbase for local-news + third-party supplier ordering
Observability Arize Phoenix traces the full decision chain (inventory → forecast → reasoning → transfer → outcome)
Surfaces Next.js dashboard + Supply Exchange; Flask bridge to the engine and Redis

fetch.ai · agentverse · uagents · claude · claude-code · anthropic · claude-vision · redis · arize-phoenix · browserbase · stagehand · open-meteo · next.js · flask · python


Quick start

Prerequisites: Python 3.11+, Node 18+, Docker (for Redis), and an Anthropic API key.

# 1. Clone
git clone https://github.com/apollo-ullah/baymax-v2.git
cd baymax-v2

# 2. Python environment + engine deps
python3 -m venv .venv && source .venv/bin/activate
pip install -r backend/engine/requirements.txt

# 3. Web deps
( cd apps/web && npm install )

# 4. Secrets: copy the template, then add your key
cp .env.example .env
#    set ANTHROPIC_API_KEY=...   (REDIS_URL defaults to redis://localhost:6379)

# 5. Bring the whole stack up (Redis + Claude engine + exchange + Flask + Next.js)
./scripts/start_demo.sh

Open http://localhost:3000 for the dashboard, or http://localhost:3000/exchange for the live Supply Exchange. Stop everything with ./scripts/start_demo.sh down.

./scripts/start_demo.sh status   # show port + health status
./scripts/start_demo.sh logs     # tail the component logs
./scripts/start_demo.sh mock     # panic switch: run the web UI fully self-contained

Just the tests? No servers or API key needed:

cd backend/engine && python -m pytest tests -q

The engine, exchange, and every live dependency ship with deterministic offline harnesses, e.g. python exchange_e2e_check.py forces a price surge and asserts the circuit breaker halts.


Repository layout

Unified monorepo. See REPO_LAYOUT.md for the full map.

Path What it is
backend/engine/ Negotiation core, Supply Exchange (market maker, order book, circuit breaker), Claude multi-agent loop, offline harnesses
backend/state/ Redis schema, inventory/forecast/transfers, seed scripts
backend/fetch/ Crisis-signal fetchers (weather, NWS, USGS, WHO, CDC, news) + iMessage approval transport
backend/vision/ Shelf camera → Claude Vision → Redis
backend/tracing/ Arize Phoenix decision-chain tracing
apps/api/ Flask bridge: proxies Redis and drives the Claude engine
apps/web/ Next.js dashboard, landing page, and Supply Exchange
archive/uagents/ The award-winning Fetch.ai uAgents / Agentverse mesh (frozen, reference only)

Recognition

Built at the UC Berkeley AI Hackathon 2026, one of the world's largest collegiate AI hackathons. Baymax won Best Use of Fetch.ai Agentverse (see the Devpost submission).

Team: Erick Gomez · Tvesha Shah · Daksh Kumar · Adyan Ullah

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages