# πŸ•·οΈ 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.** [![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python&logoColor=white)](https://www.python.org/) [![CrewAI](https://img.shields.io/badge/Multi--Agent-CrewAI-BC8CFF)](https://docs.crewai.com/) [![Playwright](https://img.shields.io/badge/Browser-Playwright-2EAD33?logo=playwright&logoColor=white)](https://playwright.dev/python/) [![Tests](https://img.shields.io/badge/Tests-14%20passing-3FB950)](#testing) [![License](https://img.shields.io/badge/License-MIT-8B949E)](#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.
Multi-Agent Browser architecture: planner agent, three parallel navigator+extractor crews, shared blackboard memory, async fetch engine with proxy rotation and Playwright escalation, validator and synthesizer agents
## ▢️ See it run **AI research pipeline** β€” real output, deterministic no-LLM mode (no API key needed):
Terminal recording: mab research command producing a cited research report with engine stats
**Bulk scraping engine** β€” measured throughput with live 100K+/day projection:
Terminal recording: mab scrape command crawling a website with throughput stats
**Real-browser rendering** β€” when plain HTTP is not enough:
Terminal recording: mab fetch --render loading a page with headless Chromium
--- ## 🧠 How it works
Pipeline: goal in, planner, three parallel research crews, shared blackboard, validation, final report
**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:
Error recovery: retry with backoff for timeouts, proxy rotation with exponential cooldown for 403/429, Playwright escalation, and learned site hints
- **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
Use cases: AI research reports, site-wide data extraction, LLM/RAG datasets, monitoring and competitive intelligence
| 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