|
1 | | -# Swarm Research |
| 1 | +# Swarm Researcher Example |
2 | 2 |
|
3 | | -#TODO: Handoff between planner and researcher |
| 3 | +A two-phase multi-agent system that demonstrates an effective collaborative approach to planning and research tasks. This example showcases a pattern used in many deep research systems: |
4 | 4 |
|
5 | | -## Quickstart |
6 | | -``` |
7 | | -uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev |
8 | | -``` |
9 | | - |
10 | | -## Search Tools |
11 | | - |
12 | | -### Playwright Browser Tool |
13 | | - |
14 | | -[Playwright](https://playwright.dev/) offers several advantages over API-based solutions: |
15 | | - |
16 | | - 1. Full browser access - can interact with entire websites, not just search results |
17 | | - 2. Can navigate complex pages, fill forms, click buttons like a human user |
18 | | - 3. Handles JavaScript-rendered content that APIs can't access |
19 | | - 4. Maintains session state across multiple interactions |
20 | | - 5. Better evades anti-scraping measures by mimicking legitimate browser traffic |
21 | | - 6. Can extract specific data elements from pages with precision |
22 | | - 7. Works well for research requiring deep site exploration |
23 | | - |
24 | | -## Troubleshooting |
| 5 | +1. **Planning Phase**: A dedicated planner agent clarifies requirements, reads documentation, and develops a structured approach |
| 6 | +2. **Research Phase**: A researcher agent implements the solution based on the planner's guidance |
25 | 7 |
|
26 | | -### Playwright MCP Server |
| 8 | +## How It Works |
27 | 9 |
|
28 | | -Some issues with the Playwright MCP Server are related to the npx cache. |
| 10 | +- The system starts with the **planner agent** that: |
| 11 | + - Analyzes the user's request |
| 12 | + - Reads relevant documentation |
| 13 | + - Asks clarifying questions to refine scope |
| 14 | + - Creates a structured plan with clear objectives |
| 15 | + - Identifies the most relevant resources for implementation |
| 16 | + - Hands off to the researcher agent |
29 | 17 |
|
30 | | -Clear the npx cache: |
31 | | -``` |
32 | | -rm -rf ~/.npm/_npx/9833c18b2d85bc59 |
33 | | -``` |
| 18 | +- The **researcher agent** then: |
| 19 | + - Follows the structured plan from the planner |
| 20 | + - Reads the recommended documentation sources |
| 21 | + - Implements the solution to satisfy all requirements |
| 22 | + - Can request additional planning if needed |
34 | 23 |
|
35 | | -Create a minimal package.json: |
36 | | -``` |
37 | | -cat > package.json << EOF |
38 | | -{ |
39 | | - "name": "zod-fix", |
40 | | - "private": true, |
41 | | - "dependencies": { |
42 | | - "zod": "3.22.4", |
43 | | - "@playwright/mcp": "latest" |
44 | | - } |
45 | | -} |
46 | | -EOF |
47 | | -``` |
48 | | -Install the dependencies: |
49 | | -``` |
50 | | -npm install |
51 | | -``` |
| 24 | +This pattern demonstrates how breaking complex tasks into planning and execution phases can lead to more thorough, well-researched outcomes. |
52 | 25 |
|
53 | | -Create the MCP server: |
54 | | -``` |
55 | | -npx @playwright/mcp |
56 | | -mkdir -p ./node_modules/zod/lib/locales |
57 | | -echo 'export const errorMap = () => ({ message: "" });' > ./node_modules/zod/lib/locales/en.js |
58 | | -``` |
59 | | - |
60 | | -Run server in isolation, which will use `stdio` transport: |
61 | | -``` |
62 | | -npx @playwright/mcp |
63 | | -``` |
64 | | - |
65 | | -Test with MCP inspector: |
66 | | -``` |
67 | | -npx @modelcontextprotocol/inspector |
68 | | -``` |
69 | | - |
70 | | -Supply the path to npx directly in your MCP configuration: |
71 | | -``` |
72 | | -{ |
73 | | - "mcpServers": { |
74 | | - "playwright": { |
75 | | - "command": "npx", |
76 | | - "args": ["@playwright/mcp"], |
77 | | - } |
78 | | - } |
79 | | -} |
80 | | -``` |
| 26 | +## Quickstart |
81 | 27 |
|
| 28 | +```bash |
| 29 | +uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev |
| 30 | +``` |
0 commit comments