Output will stream here when you run the agent.
Summary
The Deep Search Agent is a multi-agent system that researches questions through an iterative process. It clarifies user intent, plans search queries, evaluates results for completeness, and synthesizes a comprehensive answer. The system uses 4 specialized agents working together in a workflow to produce well-researched, cited answers.
Installation
$ pnpm dlx shadcn@latest add @agentcn/mastra/deep-search
Composition
├── config.ts # Main agent config with workflow
├── instructions.md # Main agent instructions
├── subagents/
│ ├── intent-clarifier/
│ │ ├── config.ts # Intent clarifier config
│ │ └── instructions.md # Generates clarifying questions
│ ├── research-planner/
│ │ ├── config.ts # Research planner config
│ │ └── instructions.md # Writes search queries
│ ├── search-result-evaluator/
│ │ ├── config.ts # Search evaluator config
│ │ └── instructions.md # Evaluates result quality
│ └── answerer/
│ ├── config.ts # Answerer config
│ └── instructions.md # Synthesizes final answer
├── skills/
│ └── research/
│ └── SKILL.md # Research procedure
└── workflows/
└── deep-search.ts # Orchestrates all agentsHow It Works
- Clarify Intent - The intent-clarifier agent asks 3 clarifying questions to understand the user's needs
- Plan Queries - The research-planner agent generates 3-5 search queries based on the clarified intent
- Search - The system executes searches using Bright Data SERP API
- Evaluate - The search-result-evaluator agent checks if results are sufficient
- Iterate - If results are insufficient, the system loops back to step 2 (up to 4 iterations)
- Answer - The answerer agent synthesizes a comprehensive, cited answer
Environment Variables
BRIGHTDATA_API_KEY= # Required: Bright Data API key
BRIGHTDATA_SERP_ZONE= # Optional: Bright Data SERP zone (defaults to "serp_api")Customization
- Search provider. Replace the
performSearchfunction inworkflows/deep-search.tswith another provider like Exa, SerpAPI, or Google Custom Search. - Swap models. Edit the
modelfield in each subagent'sconfig.ts. - Adjust iterations. Modify the loop limit in
workflows/deep-search.ts(currently 4). - Add more agents. Create new subagents under
subagents/and wire them into the workflow.