This project implements a sophisticated multi-agent research system based on the concepts described in Anthropic's article: Building a Multi-Agent Research System. The system leverages the power of coordinated AI agents to handle deep and complex research queries that require multiple perspectives and iterative investigation. The system is built around a Lead Research Agent that orchestrates the e
Add this skill
npx mdskills install gemy411/multi-agents-researchWell-architected multi-agent research framework with clear component descriptions and comprehensive documentation
1# Multi-Agent Research System23This project implements a sophisticated multi-agent research system based on the concepts described in Anthropic's article: [Building a Multi-Agent Research System](https://www.anthropic.com/engineering/built-multi-agent-research-system). The system leverages the power of coordinated AI agents to handle deep and complex research queries that require multiple perspectives and iterative investigation.45## Overview67The system is built around a **Lead Research Agent** that orchestrates the entire research process. This lead agent has access to a powerful `deployAgent` tool that can dynamically create specialized **Research Subagents** to handle specific aspects of complex queries. The lead agent can deploy multiple subagents simultaneously and can choose to deploy additional subagents after each iteration based on the evolving needs of the research task.89This multi-agent architecture enables the system to:10- Break down complex queries into manageable sub-tasks11- Perform parallel research across multiple domains12- Iterate and refine research based on intermediate findings13- Synthesize results from multiple specialized agents1415## Architecture1617### System Components1819```20┌─────────────────────────────────────────────────────────────────┐21│ Client Request │22└─────────────────────┬───────────────────┬───────────────────────┘23 │ │24 ┌──────▼──────┐ ┌──────▼──────┐25 │ MCP Tool │ │ REST API │26 │"DeepResearch"│ │ /search │27 └──────┬──────┘ └──────┬──────┘28 │ │29 └──────┬────────────┘30 │31 ┌─────────────▼─────────────┐32 │ Lead Research Agent │33 │ ┌─────────────────────┐ │34 │ │ deployAgent Tool │ │35 │ └─────────────────────┘ │36 │ ┌─────────────────────┐ │37 │ │ completeTask │ │38 │ └─────────────────────┘ │39 └─────────────┬─────────────┘40 │41 ┌────────────────┼────────────────┐42 │ │ │43 ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐44 │ Subagent │ │ Subagent │ │ Subagent │45 │ 1 │ │ 2 │ │ N │46 │ ┌───────┐ │ │ ┌───────┐ │ │ ┌───────┐ │47 │ │Search │ │ │ │Search │ │ │ │Search │ │48 │ └───────┘ │ │ └───────┘ │ │ └───────┘ │49 │ ┌───────┐ │ │ ┌───────┐ │ │ ┌───────┐ │50 │ │ Fetch │ │ │ │ Fetch │ │ │ │ Fetch │ │51 │ └───────┘ │ │ └───────┘ │ │ └───────┘ │52 └───────────┘ └───────────┘ └───────────┘53 │ │ │54 └───────────────┼───────────────┘55 │56 ┌───────────▼───────────┐57 │ Sonar Search │58 │ Manager │59 │ ┌─────────────────┐ │60 │ │ Web Search │ │61 │ │ Content Fetch │ │62 │ └─────────────────┘ │63 └───────────────────────┘64```6566### Lead Research Agent6768The **Lead Research Agent** is the orchestrator of the entire system. It:6970- **Analyzes** incoming complex queries and determines the best approach71- **Deploys** multiple subagents using the `deployAgent` tool72- **Coordinates** parallel research activities73- **Synthesizes** results from all subagents into comprehensive answers74- **Iterates** by deploying additional subagents based on intermediate findings75- **Manages** conversation history and compresses it when needed (>20 messages)7677**Key Features:**78- Uses Gemini Pro model for advanced reasoning79- Supports up to 50 iterations for complex tasks80- Parallel tool execution capabilities81- Dynamic subagent deployment and management8283### Research Subagents8485**Research Subagents** are specialized agents created by the lead agent to handle specific research tasks. Each subagent:8687- **Focuses** on a specific aspect of the research query88- **Searches** the web using natural language queries89- **Fetches** detailed content from specific URLs90- **Reports** findings back to the lead agent9192**Key Features:**93- Uses Gemini Flash model for efficient processing94- Optimized for focused research tasks (30 iterations max)95- Equipped with web search and content fetching tools96- Unique identification for tracking and coordination9798### Agent Workflow991001. **Query Reception**: Complex research query received via MCP or REST API1012. **Analysis**: Lead agent analyzes the query and creates research strategy1023. **Deployment**: Lead agent deploys initial set of subagents with specific tasks1034. **Parallel Research**: Multiple subagents work simultaneously on different aspects1045. **Progress Evaluation**: Lead agent evaluates intermediate results1056. **Iterative Deployment**: Additional subagents deployed if needed1067. **Synthesis**: Lead agent combines all findings into comprehensive answer1078. **Response**: Final research results returned to client108109## Technology Stack110111### Koog Framework112This implementation is built using the [Koog AI Framework](https://docs.koog.ai/), a Kotlin-based framework for building sophisticated AI agent systems. Koog provides:113114- **Agent Management**: Core agent lifecycle and execution management115- **Tool Registry**: Dynamic tool registration and execution116- **Strategy Patterns**: Declarative agent behavior definition117- **Prompt Management**: Sophisticated prompt engineering capabilities118- **Model Integration**: Support for multiple LLM providers119120### Key Dependencies121- **Koog Agents Core**: `ai.koog.agents.core.*` - Main agent framework122- **Koog Prompts**: `ai.koog.prompt.dsl.*` - Prompt engineering tools123- **Ktor**: Web server and HTTP client functionality124- **Model Context Protocol**: MCP integration for external tool access125- **OpenRouter**: LLM model access and execution126127## API Interfaces128129The system exposes its functionality through two interfaces:130131### 1. Model Context Protocol (MCP)132The system implements MCP to expose the `DeepResearch` tool, allowing integration with MCP-compatible clients:133134```json135{136 "tool": "DeepResearch",137 "arguments": {138 "query": "Your complex research question here"139 }140}141```142143### 2. REST API144A standard HTTP API is also available:145146```bash147GET /search?query=Your%20complex%20research%20question%20here148```149150Both interfaces use the same underlying Lead Research Agent and provide identical functionality.151152## Usage Examples153154### Complex Research Query155```156Query: "Compare the latest developments in quantum computing approaches by major tech companies and analyze their potential impact on cryptography"157158Process:1591. Lead agent analyzes the multi-faceted query1602. Deploys subagents for:161 - IBM quantum computing developments162 - Google quantum computing research163 - Microsoft quantum initiatives164 - Quantum cryptography implications1653. Subagents perform parallel research1664. Lead agent evaluates findings and deploys additional subagents for:167 - Timeline comparisons168 - Technical depth analysis1695. Final synthesis into comprehensive report170```171172### Multi-Domain Investigation173```174Query: "Investigate the economic, environmental, and social impacts of vertical farming adoption in urban areas"175176Process:1771. Lead agent identifies three main research domains1782. Simultaneously deploys subagents for:179 - Economic analysis and market data180 - Environmental impact studies181 - Social and community effects1823. Each subagent conducts focused research in their domain1834. Lead agent synthesizes cross-domain insights1845. Additional subagents deployed for comparative analysis185```186187## Installation & Running188189### Environment Setup190Configure your environment variables by copying the example environment file:191```bash192# Copy the example environment file193cp example.env .env194195# Edit the .env file with your API keys and port configuration196# The .env file should contain:197OPEN_ROUTER_API_KEY="your_api_key_here"198PORT=4321 # Optional: server port (defaults to 8080)199```200201### Building & Running202203```bash204# Build the project205./gradlew build206207# Run the server208./gradlew run209210```211212### Server Startup213When the server starts successfully, you'll see:214```215Application started in 0.303 seconds.216Responding at http://0.0.0.0:8080217```218219## Configuration220221### Agent Configuration222- **Lead Agent**: Gemini Pro model, 50 max iterations, history compression223- **Subagents**: Gemini Flash model, 30 max iterations, focused tools224- **Parallel Execution**: Enabled for both agent types225- **Tool Registry**: Dynamic tool registration and management226227### Search Configuration228- **Search Provider**: Sonar Search Manager (using Sonar by Perplexity model)229- **Model Selection**: OpenRouter is used across the entire application to access different models, including the Sonar by Perplexity model for search functionality230- **Content Fetching**: Content extraction from web pages231- **Natural Language Results**: Processed search results in conversational format232233## Development234235### Project Structure (Non-Final)236```237src/..238├── agents/239│ ├── lead/ # Lead Research Agent implementation240│ ├── subagent/ # Research Subagent implementation241│ ├── search/ # Search functionality242│ ├── models/ # LLM model configurations243│ └── prompts/ # Prompt templates and factory244├── mcp/ # Model Context Protocol integration245├── Application.kt # Main application entry point246└── Routing.kt # API routing configuration247```248249### Key Classes250- `LeadResearchAgent`: Main orchestrating agent251- `ResearchSubagent`: Specialized research agents252- `ResearchLeadAgentTools`: Tools available to lead agent (deployAgent, completeTask)253- `ResearchSubagentTools`: Tools available to subagents (webSearch, webFetch)254- `SonarSearchManager`: Search and content fetching implementation255256**Note:** The complete task tool is now useless.257## Contributing258259This project demonstrates multi-agent coordination and can be extended with:260- Optimizing parallel processing261- Manage agent memory to save context window262- Enhanced search capabilities263- Integration with more LLM providers264- Functional citation management265- Performance monitoring and analytics266267**For more details check the [Roadmap.md](ROADMAP.md)**268269---270271*Built with the [Koog AI Framework](https://docs.koog.ai/) - A powerful Kotlin framework for building sophisticated AI agent systems.*272273
Full transparency — inspect the skill content before installing.