Skip to content

Commit 8cace1f

Browse files
committed
Add research example
1 parent 2cbbb08 commit 8cace1f

File tree

7 files changed

+255
-356
lines changed

7 files changed

+255
-356
lines changed

examples/research/README.md

Lines changed: 22 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,30 @@
1-
# Swarm Research
1+
# Swarm Researcher Example
22

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:
44

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
257

26-
### Playwright MCP Server
8+
## How It Works
279

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
2917

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
3423

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.
5225

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
8127

28+
```bash
29+
uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev
30+
```

examples/research/langgraph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": ["."],
33
"graphs": {
4-
"agent": "./src/agent/agent.py:make_graph"
4+
"agent": "./src/agent/agent.py:app"
55
}
66
}

examples/research/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "swarm-researcher"
33
version = "0.0.1"
4-
description = "Simple multi-agent system for research."
4+
description = "Simple multi-agent example for planning and research."
55
authors = [
66
{ name = "Lance Martin" }
77
]
@@ -15,6 +15,7 @@ dependencies = [
1515
"langchain-mcp-adapters>=0.0.5",
1616
"langgraph>=0.3.21",
1717
"langgraph-swarm>=0.0.7",
18+
"langchain>=0.3.21",
1819
]
1920

2021
[project.optional-dependencies]

0 commit comments

Comments
 (0)