Author Info
Shengrui Chen GitHub | LinkedIn
Inspiration
We started from CoffeeAGNTCY - a multi-agent coffee supply chain - and asked: what if farms could compete for orders, responses could be fast even when some agents are slow, and the whole system could be seen in one place? We wanted to turn the demo into a real marketplace with observable, resilient agents and a way to interact that does not feel like a form. That led to four parts: Scout Agent (speed), Market Agent (competitive bidding), Shared Memory (shared context), and GameView (playable supply chain).
What it does
Lungo+ is a multi-agent coffee marketplace built on AGNTCY with four main parts.
Part 1: Scout Agent
A Scout Agent probes all farms in parallel with adaptive timeouts so you get answers in about 2 seconds instead of waiting for the slowest farm. It uses asyncio.gather(), per-farm timeouts (2s, 5s, 10s escalation), and USABLE vs NEEDS_RETRY so the system can proceed with partial results and retry when needed. It integrates with the Performance Analyzer so timeouts can use historical response times.
Part 2: Market Agent
A Market Agent runs competitive auctions. It sends RFQs, collects multi-round bids from farms, and picks the best farm using price (40%), delivery time (25%), quality (20%), and performance metrics (15%) from the Performance Analyzer (response time, success rate, stability). Users can say things like "I need 200 lbs at best price" and get a winner plus a bid summary. The Market Agent works with the Scout so probing is fast and bidding is structured.
Part 3: Shared Memory
A Shared Memory service lets agents read, write, and query the same state. It uses an LRU cache for eviction, an inverted index for tag-based search, and TF-IDF for ranking search results by relevance. A Semantic Translator maps vocabularies between agents (e.g. Supervisor "order" vs Shipper "shipment" vs Accountant "transaction") so they can query shared memory in their own terms. The logistics flow (Supervisor, Farm, Shipper, Accountant) uses shared memory for order state (RECEIVED_ORDER, HANDOVER_TO_SHIPPER, CUSTOMS_CLEARANCE, PAYMENT_COMPLETE, DELIVERED). Endpoints: write, read, query by tags, semantic-search, and order state.
Part 4: GameView
GameView is a 2D top-down game in the frontend where you move with WASD, approach NPCs (e.g. Supervisor), press Space to chat, and trigger real agent workflows with streaming updates. It has a canvas game loop, tile-based collision, camera, and NPCs that call the same prompt/stream APIs as the chat UI so the game and the workflow graph stay in sync.
Together: faster decisions (Scout), better prices (Market), transparent state (Shared Memory), and an interactive front-end (GameView).
How we built it
Scout
We added a Scout that uses asyncio.gather() and per-farm timeouts. It probes all farms at once, escalates timeouts (2s to 5s to 10s) until the result is USABLE, and feeds into the Market Agent. We wired it to the Performance Analyzer (ClickHouse or mock) so timeouts can use historical data.
Market
We built a Market Agent that creates RFQs, sends them to farms over A2A, parses bids (quantity, price, delivery, quality) from farm responses, runs multi-round auctions, and scores bids using price, delivery, quality, and performance weights from the Performance Analyzer. We exposed conduct_market_auction on the Auction Supervisor and combined it with the Scout in scout_then_market_analyze_then_decide.
Shared Memory
We implemented a Shared Memory service with an LRU cache for O(1) get/put and eviction, an inverted index (tag to entry IDs) for fast tag search, and TF-IDF for ranking query results by relevance. We added a Semantic Translator with vocabulary mappings (supervisor, farm_agent, shipper, accountant) and state synonyms so agents can query shared memory in their own terms. The logistics agents (Farm, Shipper, Accountant) read and write order state and messages via shared memory. We exposed write, read, query, semantic-search, and order-state endpoints on the Logistics Supervisor.
GameView
We built a 2D engine in React/TypeScript with a canvas game loop, tile-based collision map, WASD and Space, camera, and NPCs. NPCs call the same prompt/stream endpoints as the chat UI so interactions trigger real agent workflows and streaming. Farm labels (Brazil, Colombia, Vietnam) and a Supervisor NPC are used for the coffee-buying flow.
Tech Stack
We kept the existing CoffeeAGNTCY stack: LangGraph, FastAPI, SLIM/NATS, MCP (weather, payment), OpenTelemetry, Grafana, ClickHouse, Docker Compose, and identity. Scout, Market, Shared Memory, and GameView sit on top of that.
Challenges we ran into
Scout
One slow farm used to block the whole response. We fixed it with parallel probing and progressive timeouts so we can proceed with USABLE results and retry with longer timeouts when needed.
Market
Farms return free-form text for bids. We defined a strict RFQ response format and added regex and fallback parsing (including from the user prompt) to reliably get quantity, price, delivery, and quality into the Market Agent.
Shared Memory
Different agents use different terms. We added the Semantic Translator with vocabulary mappings and state synonyms on top of Shared Memory so agents can query by tags and their own vocabulary while preserving meaning.
GameView
Keeping the 2D world (collision, NPCs, camera) in sync with agent state and streaming was tricky. We tied NPC interactions to the same prompt/stream endpoints the chat UI uses so the game and the graph stay consistent.
Accomplishments that we're proud of
We have Scout and Market in one flow: one tool that probes farms fast, collects bids, and picks a winner using price, delivery, quality, and performance-based scoring. We have three coordination patterns in one repo: Auction (supervisor-worker and broadcast), Group conversation (logistics over SLIM with shared memory), and Publish/subscribe (inventory broadcast). Shared Memory uses real algorithms (LRU cache, inverted index, TF-IDF) for state and semantic search, and the Semantic Translator lets agents use different vocabularies. GameView is a working 2D engine that calls real agent APIs and streams responses so we can show the supply chain as a playable world. All four parts (Scout, Market, Shared Memory, GameView) work together on the same AGNTCY foundation.
What we learned
Designing for partial success (Scout USABLE vs NEEDS_RETRY) makes multi-agent systems feel faster and more robust. Putting observability in the loop (traces, Performance Analyzer, Scout timeouts and Market scoring) improves UX and debuggability. A shared semantic layer (Shared Memory with LRU, inverted index, TF-IDF, plus Semantic Translator) lets agents keep their own vocabulary while sharing state. Combining game UX with real agent backends (GameView) is feasible and makes MAS demos more engaging.
What's next for Lungo+
For Scout: tighter integration with Performance Analyzer and optional per-farm policies. For Market: more rounds and optional negotiation protocols. For Shared Memory: optional backend (e.g. Redis or a database) and optional vector search alongside TF-IDF. For GameView: procedural maps, quests mapped to agent workflows, and more NPC behaviors. We also want to use the stack for MAS benchmarks and small-scale experiments.
Built With
- clickhouse
- docker
- fastapi
- langgraph
- llm
- python
- typescript
Log in or sign up for Devpost to join the conversation.