Case study
Lean Swarm
Cost-focused multi-agent simulation engine for narrative forecasting, with tiered model routing and sparse agent activation.
Highlights
- Tiered model routing (flagship/standard/cheap)
- Sparse activation keeps a subset of agents live per tick
- Benchmark harness compares lean vs naive activation on cost/quality/runtime
- Hierarchical memory with SQLite + optional vector search
Lean Swarm approximates MiroFish-class narrative forecasting: given a seed document and a prediction question, it builds a simulated population of agents, runs a bounded number of interaction ticks, and returns a structured prediction report alongside a post-simulation world snapshot of agent states and relationships.
The design is built around cost discipline. Every model call is routed through one layer with three tiers (flagship, standard, cheap), and a live simulation adds exactly one cheap-tier extraction pass over the seed document to replace a deterministic n-gram profile with typed entities and relations. Sparse activation and trigger heuristics keep only a subset of agents active on any given tick rather than simulating the whole population every round, and hierarchical memory (working, episodic, semantic) is backed by SQLite with an offline fallback when vector search isn't available.
The benchmark harness (leanswarm bench) runs the same cases in both lean and naive activation modes and reports the cost, quality, and runtime deltas between them, plus per-case plot points for a quality-vs-cost comparison. Published to PyPI with a CLI, a FastAPI server, and a minimal Next.js viewer for inspecting simulation output.