Notebooks#
One Google Colab notebook per chapter. Each runs top-to-bottom in Colab with no local setup and no API key (mock mode is the default).
Click any "Open in Colab" badge below to launch the notebook in a free Colab runtime.
Part I — The Primitives#
Chapter 1 — Token Mechanics#
Token count distribution across prompt types, cost breakdown pie chart, retry/backoff timeline. Build empirical intuition for the chars-per-token ratio that matters for budgeting.
Chapter 2 — Provider & Cache#
Side-by-side latency and cost across Anthropic, OpenAI, Gemini, Groq. Simulate the cache warmup pattern over 10 sequential calls — watch cache_read_tokens climb from zero.
Chapter 3a — The ReAct Loop#
Animated LoopState across iterations. Termination condition visualizer. Quadratic cost-growth plot proving why iteration ceilings matter.
Chapter 3b — Tools & MCP#
Tool registry inspector. Live MCP server spawn + round-trip: you write the 30-line get_time server, connect from Python, watch the handshake, extend with a second tool, see list_tools() grow.
Part II — State, Collaboration & Measurement#
Chapter 4 — Memory Visualization#
Three-layer memory growth across a simulated session. autoDream consolidation before/after. Topic file count over sessions with the triple-gate firing visualization.
Chapter 4b — Vector Memory (bonus)#
tfidf backend + optional sentence-transformers comparison. Paraphrase-query demo showing why keyword search loses on "database costs exploded" → "unusual AWS bill on Sunday". Cosine-similarity histogram.
Chapter 5 — Eval & Pareto Frontier#
LLM-as-judge harness in action. Position-bias visualization across N pairwise runs. Pareto frontier scatter plot (cost × accuracy) with the dominated-by-all-axes region highlighted.
Part III — Scale, Safety & Production#
Chapter 6 — Fork-Join#
Worker timing chart (Gantt-style). Cache-inheritance savings visualization. Parallelism-vs-cost tradeoff across N=1..8 workers.
Chapter 7 — Cost Routing (interactive)#
Interactive ipywidgets sliders for tier routing threshold. Watch the cost distribution update live. Five compaction strategies side-by-side on a shared fixture conversation.
Chapter 8 — Daemon & Plugins#
KAIROS daemon tick-log replay rendered as a timeline. Skill library retrieval demo. Real Claude Code plugin directory structure walkthrough.
Chapter 9 — Capstone Benchmarks#
SWE-bench Lite + GAIA Level 1 runs in mock mode. Results table. Final Pareto plot showing cost × pass-rate across each model configuration.
How to run these locally (optional)#
If you prefer Jupyter on your machine over Colab:
git clone https://github.com/TheAiSingularity/crafting-agentic-swarms.git
cd crafting-agentic-swarms
pip install -e ".[dev]"
pip install jupyter mkdocs-jupyter matplotlib plotly ipywidgets
SWARM_MOCK=true jupyter lab notebooks/
Mock mode is the default; no API key required.