← All projects

Weekend Swarm

0 comments

What it does

Weekend Swarm plans a UK day trip (York, Edinburgh or Bath) for a given date, budget and tastes, using a swarm of concurrent Mozaik agents on one shared board. FoodScout, CultureScout, LogisticsScout and BudgetKeeper claim time slots in parallel. A Critic agent flags clashes as they happen (overlapping times, walks too long for the gap, outdoor stops in rain, over budget, a place that just became unavailable), and the scout at fault re-plans while the others keep working. A Composer agent then writes a clash-free Markdown itinerary. It runs fully offline with no API keys (`npm install && npm start`), using a seeded scripted model plugged into Mozaik as a custom InferenceRunner. It prints a live, interleaved timeline that shows the agents overlapping, ends with a concurrency summary, and writes a JSONL event log. Set ANTHROPIC_API_KEY or OPENAI_API_KEY to use a real model instead; hard caps on calls and tokens apply.

How the agents run concurrently

Four scout agents run at the same time: FoodScout, CultureScout, LogisticsScout and BudgetKeeper. One Traveller message.sent triggers a situation handler on each, and each calls Mozaik's fire-and-forget runLoop in the same tick, so four loops (inference -> tool call -> inference...) are in flight together. In the default run, all four model calls are in flight at once. Shared state: a TripBoard subclass of Mozaik's RuntimeState holds the day's slots, every claim (place, time, cost, lat/lon), budget allowances, weather, notes and conflicts. Scouts write it through tools (claim_slot, release_slot, set_allowances, post_note) without locks, so their parallel first drafts really collide: a 3-hour museum runs into lunch, an outdoor walk lands in the rain, the plan goes over budget. Coordination is purely by events. Each change publishes a custom board.changed event. A Critic agent re-checks five rules on every change and publishes conflict.raised naming the owner scout. Only that scout's AddressedToMe handler fires, and it starts a REPLAN loop (or queues it until its current loop ends). The other scouts are never paused: in the timeline, FoodScout re-plans its tea stop while CultureScout is still drafting, and BudgetKeeper starts an advise loop on the over-budget event in parallel with both. When a fix lands, the Critic publishes conflict.resolved. A clash that survives a re-plan is re-raised to the other side or the next overspender, and waived after three tries, so runs never hang. A Composer agent listens for model.answer and conflict.resolved, and once every scout is idle, all slots are filled and no conflict is open, it runs its own loop to publish the itinerary. An observer participant sees every event; it prints an interleaved timeline with a live "who is mid-loop" gauge and ends with stats: per-agent active intervals, the most agents active at once (4) and the share of busy time with 2 or more active (~60%).

Comments

No comments yet.

Sign in to like and comment