DOC.10 20 REPOS
AGENT SWARM COST ARCHITECTURE · @IRONGIANTXBT

20 Open-Source Repos to Cut Agent Spend at the Four Leak Points

Core engineering thesis: Agent swarms don’t go broke on intelligence—they bleed tokens on two silent leaks: reading raw layouts/logs the task never needed and recomputing finished work. Diagnose your exact leak below to generate a minimal 3–4 repo starter stack instead of installing all 20 on Day 1.

Post Claim (Unoptimized)$4,500 / wk
Post Target (4-Stage)<$0.02 / bot / wk
Swarm Cited300 Grok Bots
Original Iron Giant research note infographic: 20 GitHub repos to make Grok Bot setup cheaper
FIG.00 · Original X Infographic4 Stages · 20 Live GitHub Links

Shrinking Token-Leak Funnel (Execution Order)

FIG.01 · WATERFALL
100% RAW UNOPTIMIZED AGENT SPEND Raw HTML/PDFs + full chat replay + idle cron LLMs + infinite API retries STAGE I · FILTER BEFORE READING (01–06) MarkItDown · LLMLingua · Firecrawl · RTK · Chonkie · FlagEmbedding STAGE II · REUSE BEFORE GENERATING (07–11) Mem0 · Prefect · GPTCache · Graphiti · Portkey Gateway STAGE III · CHECK IN CODE FIRST (12–15) Hishel · Celery · requests-cache · APScheduler STAGE IV · ROUTE & CAP (16–20) RouteLLM · Phoenix · PyBreaker · LiteLLM ▼ ONLY HIGH-SIGNAL, UNSEEN, BUDGET-CAPPED CALLS HIT FRONTIER MODELS

Interactive Symptom → Minimal Starter Stack

DIAGNOSTIC
RECOMMENDED MINIMAL STARTER STACK (HIGHLIGHTED BELOW)
MarkItDown + RTK · Mem0 + Portkey Gateway · LiteLLM + PyBreaker
pip install markitdown mem0ai litellm pybreaker

Complete 20-Repository Engineering Spec Matrix

#ToolStageExact Leak EliminatedGitHub Repository
01MarkItDownI · FILTERConverts PDFs, Office docs & HTML to clean Markdown (drops layout junk).microsoft/markitdown ↗
02LLMLinguaI · FILTERCompresses long prompts & transcripts while preserving task-critical facts.microsoft/llmlingua ↗
03FirecrawlI · FILTERScrapes sites into clean Markdown/JSON keeping only fields the agent needs.firecrawl/firecrawl ↗
04RTKI · FILTERCompresses noisy CLI output (git, tests, build logs) before context injection.rtk-ai/rtk ↗
05ChonkieI · FILTERSplits manuals & reports cleanly so retrieval pulls paragraphs, not whole PDFs.feyninc/chonkie ↗
06FlagEmbeddingI · FILTERReranks retrieved chunks pre-generation so weak matches never burn tokens.flagopen/flagembedding ↗
07Mem0II · REUSEPulls selective learned memory across runs instead of replaying full history.mem0ai/mem0 ↗
08PrefectII · REUSECaches finished workflow task outputs and skips rerun when inputs match.prefecthq/prefect ↗
09GPTCacheII · REUSEServes saved answers to semantically similar prompts with configurable TTL.zilliztech/gptcache ↗
10GraphitiII · REUSETracks changing entities (prices, owners) in a temporal graph vs. raw logs.getzep/graphiti ↗
11Portkey GatewayII · REUSECentral AI gateway sharing cached responses across every bot in a swarm.portkey-ai/gateway ↗
12HishelIII · POLLAdds RFC HTTP caching/304 revalidation to httpx so unchanged endpoints sleep.karpetrosyan/hishel ↗
13CeleryIII · POLLMoves waiting, retries & dispatch onto cheap queues outside LLM calls.celery/celery ↗
14requests-cacheIII · POLLPersists Python HTTP responses with expiry before waking an agent.requests-cache/requests-cache ↗
15APSchedulerIII · POLLRuns lightweight cron checks in plain Python & batches non-urgent diffs.agronholm/apscheduler ↗
16RouteLLMIV · CAPSends simple tasks to cheap models; reserves frontier models for hard steps.lm-sys/routellm ↗
17PhoenixIV · CAPTraces agent runs to expose repeated calls & verify quality before cutting cost.arize-ai/phoenix ↗
18PyBreakerIV · CAPTrips circuit breaker on flaky APIs to stop runaway retry billing loops.danielfm/pybreaker ↗
19Semantic RouterIV · CAPRoutes user intents via fast local embeddings instead of LLM tool-selection.aurelio-labs/semantic-router ↗
20LiteLLMIV · CAPEnforces hard per-key dollar spend limits across providers before runaway bills.berriai/litellm ↗

4-Step Rollout Discipline

SOP

1. Trace First (Phoenix + LiteLLM): Measure real token spend and set hard dollar caps before optimizing.
2. Single Gateway: Route all bots through Portkey or LiteLLM so caching/budgets actually apply.
3. Plug #1 Leak First: Use the diagnostic checklist above—never deploy 20 libraries on Day 1.
4. Count Infra Overhead: Track embedding/worker costs alongside token savings per finished task.

Verification & Fact Boundary

AUDIT

Headline anecdote unverified: The viral hook (“300 Grok bots at <$0.02/bot/wk vs. $4,500/wk”) is reported in Iron Giant’s post without a public invoice audit.
All 20 repos verified real: Every linked repo above is an established open-source library across Microsoft, Prefect, Zilliz, Arize, Mem0, Portkey, and LiteLLM.