π Hackapizza 2.0 - Winning an AI Agents Hackathon
what a weekend!! on february 28th and march 1st, our team βCavalli al trotto πβ won π Hackapizza 2.0: Agent Edition, the hackathon organized by Datapizza in Milan β one of the most intense and stimulating competitions iβve ever taken part in.
24 hours non-stop designing, testing and stress-testing advanced agentic systems, competing against 120 selected participants from all over Italy.
the team was composed of Giacomo Pacini, Dario Cioni, Alessio Chen and me.
π The Challenge
the hackathon track was βgalacticβ themed, building on the first edition: participants had to build a fully autonomous virtual restaurant β no human intervention allowed.
the AI agents had to independently:
- purchase ingredients through a blind auction
- define the menu and prices dynamically
- exchange ingredients between competing teams
- serve incoming clients, managing queues and priorities
- read a blog with βnewsβ and market trends
- analyze competitors and the market to maximize revenue
the competition used the datapizza-ai open-source agentic framework, with API inference provided by Regolo.ai, a european LLM inference provider.
π€ System Architecture
we built a real-time multi-agent system that simulates running a restaurant in an alien universe. five specialized AI agents compete against other restaurants to maximize profit through intelligent decision-making.
Agents
| agent | phase | purpose |
|---|---|---|
| menu agent | speaking / waiting | decide dishes and pricing |
| bid agent | closed_bid | determine ingredient bids |
| allergy agent | serving | extract allergies & intolerances from order text |
| service agent | serving | match client order to a safe dish |
| memory agent | stopped | generate turn summaries and lessons learned |
Turn Structure
each game turn progresses through five sequential phases:
| phase | purpose | key actions |
|---|---|---|
| speaking | planning & diplomacy | open restaurant, decide menu, negotiate |
| closed bid | ingredient procurement | submit blind bids in auction |
| waiting | strategic adjustment | adjust menu based on actual inventory |
| serving | customer service | cook and deliver dishes to clients |
| stopped | end-of-turn analysis | generate summary, clear transient state |
critical rule: ingredients expire at the end of each turn β unsold inventory is lost. this pushed us to design a bidding agent that estimated demand carefully rather than over-buying.
βοΈ How It Works
the system is entirely event-driven: an SSE loop is the heartbeat, and every game event triggers a handler that updates in-memory state and schedules background work without blocking the loop.
1
2
3
4
5
6
7
8
9
10
11
12
game server (SSE)
β
βΌ
βββββββββββββββ game_phase_changed ββββββββββββββββββββββββββββββββββββββββββββ
β SSE loop β βββββββββββββββββββββββΊ β orchestrator (background task) β
β (main.py) β β β
β β client_spawned β speaking βββΊ menu_agent βββΊ save_menu β
β β βββββββββββββββββββββββΊ β closed_bid βββΊ bid_agent βββΊ closed_bidβ
β β preparation_complete β waiting βββΊ menu_agent βββΊ save_menu β
β β βββββββββββββββββββββββΊ β serving βββΊ per-client flow β
βββββββββββββββ β stopped βββΊ memory_agent βββΊ db summaryβ
ββββββββββββββββββββββββββββββββββββββββββββ
Per-Client Serving Flow
when a client_spawned event arrives, the orchestrator processes the client in a dedicated async task:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
client_spawned { clientName, orderText }
β
βΌ
1. allergy_agent βββΊ detect allergies from free-form order text
β
βΌ
2. pre-filter menu βββΊ remove any dish containing a forbidden ingredient
β
βΌ
3. service_agent βββΊ pick the best safe dish from the filtered menu
β (defense-in-depth re-check if LLM picked unsafe dish)
βΌ
4. prepare_dish (MCP) βββΊ wait for preparation_complete SSE event
β
βΌ
5. serve_dish (MCP) βββΊ meal delivered, logged to DB
if any step fails, the orchestrator falls back to a deterministic dish picker that also enforces allergy constraints.
π§© Key Architectural Decisions
Long-Term Memory
one of the main challenges of the hackathon was managing long-term memory across game turns. the memory agent generates structured turn summaries β lessons learned, bidding outcomes, competitor behavior β that are persisted to MySQL and fed back into the next turnβs planning.
State Persistence
every decision and tool call is persisted to MySQL in real time:
1
2
3
4
5
6
7
8
9
10
allergy_agent decision ββ
menu_agent decision ββ€βββΊ decisions table
bid_agent decision ββ€
service_agent decision ββ
prepare_dish / serve_dish ββ
save_menu / closed_bid βββββΊ mcp_calls table (with latency_ms)
game_phase_changed ββ
client_spawned βββββΊ sse_events table
Deterministic Fallbacks
every AI agent has a deterministic fallback path β this was critical to avoid losing turns when LLM calls timed out under high concurrency during the competition.
π Project Structure
1
2
3
4
5
6
7
8
9
10
11
12
hackapizza2.0/
βββ main.py # entry point: SSE listener & event dispatcher
βββ hackapizza/
β βββ agents.py # AI agents (menu, bid, service, memory, allergy)
β βββ context.py # AppContext & GameState singleton
β βββ db.py # MySQL persistence layer
β βββ http_client.py # game API HTTP client
β βββ mcp_actions.py # MCP tool invocation client
β βββ orchestrator.py # phase coordinator & agent orchestrator
βββ hackapizza-dashboard/ # git submodule: monitoring dashboard
βββ recipes-analysis/ # 900+ recipes dataset & analysis
βββ docker-compose.yml # MySQL + Redis + dashboard services
π οΈ Tech Stack
- language: Python 3.12+ (async/await)
- AI framework: datapizza-ai
- LLM provider: Regolo.ai (OpenAI-compatible, european)
- networking: aiohttp (SSE + HTTP), JSON-RPC
- database: MySQL 8.4, Redis 7 (Docker)
- dependency management: uv
π¬ Conclusion
this was one of the most technically demanding competitions iβve experienced. the combination of multi-agent orchestration, real-time event-driven architecture, complex game theory decisions and very tight time constraints made every hour count.
beyond the technical side, it was great to meet and exchange ideas with other AI enthusiasts and professionals from all over Italy β discussing architectural patterns, agent design choices and future directions for AI systems.
a special thanks to the entire Datapizza team for organizing such an impeccable event, and to the jury: Simone Rizzo, Enrico Mensa, Giuseppe Gullo, and Giacomo Ciarlini.
π GitHub Repository
visit the project repository here for accessing the full codebase (if you enjoyed this content, please consider leaving a star β).









