What This Example Shows
- The enterprise pattern: kick off a long batch of independent multi-agent swarms at end-of-day, have results waiting at 7am
- A real due-diligence workload across 50 portfolio companies
- How to schedule with cron, persist results, and recover from partial failures
- Concrete cost framing versus a human research desk
- Why this is materially different from running each swarm one at a time
Why This Matters
A single multi-agent swarm — director plus three specialists — does the work of an analyst team over a 30-minute call. But the real enterprise pattern isn’t one swarm. It’s fifty swarms running while everyone sleeps: one per portfolio company, one per RFP response, one per region for a market scan, one per candidate in a final-round panel. Schedule a batch swarm job at 8pm, have a folder of completed due-diligence memos waiting at 7am. This tutorial shows how to build that job.Step 1: Setup
Step 2: Define a Reusable Due-Diligence Swarm Template
Every swarm in the batch is a fullSwarmSpec. We define one template (a four-agent HierarchicalSwarm) and stamp it out per company.
Step 3: Build the 50-Company Batch
In a real workload, the watchlist comes from a portfolio database. Here we hard-code 50 tickers.Step 4: Submit the Overnight Job
One POST. The server parallelizes the swarms behind the gateway.The endpoint returns one entry per swarm in the same order as the request, each with its own
job_id, status, usage, and output. Persist the array to disk before you start parsing — partial network failures are easier to recover from when you have the raw response saved.Step 5: Persist Per-Memo Files
Drop one Markdown file per company into a dated folder so your team finds the memos waiting in the morning.Step 6: Schedule the Overnight Run
The simplest production deploy is a cron job on a small VM or a scheduled GitHub Action. Save the script above asnightly_dd.py and add to crontab:
For zero-infrastructure scheduling, use a serverless cron platform (GitHub Actions
schedule: cron, AWS EventBridge, Vercel Cron). The job itself is a single Python script — anywhere that can run Python on a schedule will work.Recovering From Partial Failures
Each entry in the response carries its ownstatus. Retry only the failed ones — never resubmit the full batch.
The Cost Math
Pricing varies by model and current token rates — these numbers are illustrative.| Approach | Wall time | Direct cost | Burdened cost |
|---|---|---|---|
| Junior analyst team writing 50 DD memos | ~250 hours (5 hrs per memo) | $25,000 at $100/hr | $40,000+ with overhead |
| One swarm at a time, sequentially | ~5-8 hours | ~$75 | A workday of analyst babysitting |
| Batch swarm overnight, one POST | ~30-60 minutes server-side | ~$75 | $75 + you were asleep |
Adapting the Pattern
The same overnight-batch shape applies to any “N independent multi-agent jobs” workload:| Workload | One swarm per… | Agents inside each swarm |
|---|---|---|
| M&A pipeline review | target company | DD director + financial + legal + technical |
| RFP response factory | open RFP | proposal lead + writer + pricing + compliance |
| Clinical literature scan | indication or molecule | senior MD + biostatistician + safety reviewer |
| Marketing market scan | geography or persona | brand lead + copywriter + designer + performance |
| Vendor security review | vendor | CISO + AppSec engineer + privacy counsel |
Next Steps
- Batch Agent Completions at Scale when a single agent per record is enough
- Batch Swarm Completions (Multi-Agent) for the request-shape reference
- Supply Chain Hierarchical Swarm for the inner hierarchical-swarm pattern this tutorial replicates 50 times