# π·οΈ Multi-Agent Browser
**Five specialized AI agents research the web together β sharing one browser session and one
collective memory β on top of a 100K+ pages/day async scraping engine.**
[](https://www.python.org/)
[](https://docs.crewai.com/)
[](https://playwright.dev/python/)
[](#testing)
[](#license)
*[Architecture](#-architecture) Β· [Demos](#-see-it-run) Β· [How it works](#-how-it-works) Β· [Use cases](#-use-cases) Β· [Quickstart](#-quickstart) Β· [Friendly guide](EXPLANATION.md) Β· [Tech deep-dive](TECH_STACK_GUIDE.md)*
---
## ποΈ Architecture
One goal goes in; a planner, three parallel agent crews, a validator, and a writer come out β
all coordinated through a shared blackboard and a single polite, proxy-rotating fetch engine.
## βΆοΈ See it run
**AI research pipeline** β real output, deterministic no-LLM mode (no API key needed):
**Bulk scraping engine** β measured throughput with live 100K+/day projection:
**Real-browser rendering** β when plain HTTP is not enough:
---
## π§ How it works
**The five agents**
| # | Agent | Job |
|---|-------|-----|
| 1 | **Planner** | Decomposes your goal into 2β5 distinct search strategies (official sources, comparisons, community, newsβ¦) |
| 2 | **Navigator** | Runs the searches, fetches pages into the shared session, follows hub links β and **refines its own queries mid-flight** |
| 3 | **Extractor** | Reads cached pages and saves crisp, sourced, tagged findings β duplicates rejected automatically |
| 4 | **Validator** | Rejects vague, off-topic or near-duplicate findings; scores what survives |
| 5 | **Synthesizer** | Writes the final Markdown report with numbered citations |
**What makes them a *team* (not 5 lone agents):**
- π **Blackboard shared memory** β one thread-safe board with strategies + live scores, deduplicated
findings, lessons, and a page cache. Every agent reads what every other agent learned.
- πͺ **Shared browser context** β every Playwright session inherits the same cookies/localStorage.
One agent solves a login or consent wall β every agent is already through it.
- π‘ **Learned site hints** β when a domain bot-blocks the HTTP path, the engine escalates to a real
browser *and remembers*, so future fetches to that site start smart.
- π **Live strategy refinement** β navigators push better queries back onto the board while crews
are still running.
## π‘οΈ Intelligent error recovery
Every failure has a plan. This ladder is why long crawls survive the real internet:
- **Timeouts / 5xx** β jittered exponential backoff, retry in place
- **403 / 429 / 503** β proxy goes into exponential cooldown (2s β 5 min cap), next proxy rotates in,
and the fetch escalates to **real Chromium rendering**
- **404-class** β fail fast, zero retries wasted
- **Blocked domains are remembered** as site hints β the system *learns* which sites need the browser
- `robots.txt` is always fetched and respected first; per-host rate limiting is always on
---
## π― Use cases
| You want⦠| Command |
|---|---|
| A cited research report on any topic | `mab research "topic"` |
| Every page of a website as structured data | `mab scrape --sitemap https://site.com/sitemap.xml --csv` |
| A text corpus for embeddings / RAG | `mab scrape --from-file urls.txt --out rag_corpus` |
| Scheduled monitoring via HTTP | `mab serve` + `POST /research` |
| One page, rendered with a real browser | `mab fetch https://example.com --render` |
---
## π Quickstart
```bash
git clone https://github.com/sanzizlohar/multi-agent-browser.git
cd multi-agent-browser
python -m venv .venv
.venv\Scripts\activate # windows (mac/linux: source .venv/bin/activate)
pip install -e ".[dev]"
playwright install chromium
copy .env.example .env # add MAB_LLM_API_KEY=... (optional!)
# demo the FULL pipeline with zero API keys:
mab research --no-llm "what is multi-agent orchestration" --out mab_output/demo
```
> **No API key? Everything still works.** Every agent has a deterministic fallback
> (`--no-llm`): template planning, keyword extraction, similarity scoring, report assembly.
> With a key, the same pipeline runs on OpenAI, Groq, Anthropic, or a local Ollama model.
### The CLI
```text
mab research "goal" AI crew researches the open web
--strategies 3 parallel search strategies (default 3)
--max-pages 8 pages fetched per strategy
--seed URL start pages, no search engine needed (repeatable)
--no-llm deterministic mode, no API key
--out DIR writes report.md + findings.json + run_stats.json
mab scrape --sitemap URL | --url URL | --from-file FILE
--depth 1 follow same-site links N levels
--limit 500 --csv --resume bounded, CSV output, resumable
--ignore-robots (default: robots.txt is respected)
mab fetch URL [--render] single-page smoke test
mab proxies health-check configured proxies
mab serve --port 8000 HTTP API mode
```
### Results land in `mab_output//`
```
report.md β final cited report
findings.json β every validated fact: title, url, content, tags, confidence
run_stats.json β pages, success rate, throughput, proxy health
pages.jsonl β (scrape mode) one JSON record per page: text, links, timings
state.sqlite3 β (scrape mode) resume checkpoint
```
## π‘ HTTP API
```bash
mab serve --port 8000
```
```bash
curl -X POST localhost:8000/research -H "Content-Type: application/json" \
-d '{"goal": "best python scraping libraries", "max_strategies": 2, "no_llm": true}'
# β {"job_id": "70494e77087c", "status": "queued"}
curl localhost:8000/jobs/70494e77087c # status + live engine stats
curl localhost:8000/jobs/70494e77087c/report # the finished markdown report
```
## π Built for 100K+ pages/day
LLMs are slow and expensive β so they **never touch the bulk path**. Agents *steer* (dozens of
pages), the engine *harvests* (hundreds of thousands):
- **20 concurrent async workers** (httpx pool) draining a **SQLite-backed frontier**
- **~2 req/s per host** politeness + global concurrency cap
- Ctrl+C anytime β `--resume` continues exactly where the run stopped
- The CLI prints **measured** pages/min and a **projected pages/day** from live traffic
```
20 workers Γ ~1 page/s β 70 pages/min β 100,000+ pages/day β at polite speed
```
## βοΈ Configuration (`.env`)
| Variable | Default | Meaning |
|---|---|---|
| `MAB_LLM_MODEL` | `openai/gpt-4o-mini` | any LiteLLM model: `groq/β¦`, `anthropic/β¦`, `ollama/β¦` |
| `MAB_LLM_API_KEY` / `OPENAI_API_KEY` | β | not needed for `--no-llm` |
| `MAB_MAX_CONCURRENCY` | `20` | global concurrent fetches |
| `MAB_PER_HOST_RATE` | `2.0` | max requests/second per host |
| `MAB_MAX_RETRIES` | `3` | retries per page |
| `MAB_PROXIES` | β | `http://user:pass@host:port, socks5://host:1080` |
| `MAB_USE_BROWSER` | `1` | Playwright fallback on/off |
| `MAB_RESPECT_ROBOTS` | `1` | robots.txt compliance |
## π§ͺ Testing
14 tests, no external network needed (local HTTP fixtures):
```bash
pytest
```
covers: retry-on-500 recovery Β· robots.txt blocking Β· proxy cooldown & recovery Β· blackboard
dedupe Β· page normalization Β· sitemap scraping Β· resume behavior Β· depth crawling Β· CrewAI tool wiring.
## π Project layout
```
src/mab/
βββ browser/ # engine (retries, proxies, robots) Β· playwright driver Β· proxy rotator Β· extraction
βββ memory/ # blackboard: strategies, findings, lessons, page cache, site hints
βββ agents/ # the 5 agents (LLM + deterministic fallbacks) Β· the 8 crew tools
βββ pipeline/ # research orchestrator: plan β parallel crews β validate β report
βββ scraper/ # bulk scraper: sqlite frontier, resume, sitemap expansion
βββ api/ # FastAPI job server
βββ cli.py # mab research | scrape | fetch | proxies | serve
docs/images/ # architecture diagrams + demo GIFs (regenerate: python scripts/make_gifs.py)
EXPLANATION.md # friendly deep-dive: analogy, step-by-step, interview Q&A
TECH_STACK_GUIDE.md # every technology: where it's used, why, and interview answers
```
## πΊοΈ Roadmap
- [ ] Redis-backed frontier for multi-machine crawling
- [ ] Vector-memory (semantic dedupe + retrieval) on the blackboard
- [ ] Live dashboard fed by the blackboard event stream
- [ ] Pluggable extractors (trafilatura, tables, PDFs)
## βοΈ Responsible use
robots.txt compliance is on by default, per-host rate limiting is always on, and the engine uses a
standard browser user-agent. Scrape what you're allowed to scrape and keep the rate polite.
## π License
MIT
---
Built with Python 3.12 Β· CrewAI Β· Playwright Β· httpx Β· FastAPI Β· SQLite Β· BeautifulSoup