Purpose
This project implements a multi-agent research system for handling deep, complex research queries that require multiple perspectives and iterative investigation. It can be used both for coding assistance and for general research tasks. The system is built on the concepts described in the Anthropic article "Building a Multi-Agent Research System," completing research by coordinating multiple AI agents.
Main Capabilities
The system is orchestrated around a Lead Research Agent, which has 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 more subagents after each iteration based on the continuously changing needs of the research task.
This multi-agent architecture enables the system to:
- Decompose complex queries into manageable subtasks
- Perform parallel research across multiple domains
- Iterate and refine based on intermediate findings
- Synthesize results from multiple specialized agents
Lead Research Agent
The Lead Research Agent is the orchestrator of the entire system. It:
- Analyzes incoming complex queries and determines the best approach
- Uses the deployAgent tool to deploy multiple subagents
- Coordinates parallel research activities
- Synthesizes the results of all subagents into a comprehensive answer
- Iteratively deploys additional subagents based on intermediate findings
- Manages conversation history and compresses it when needed (after more than 20 messages)
- Uses the Gemini Pro model for advanced reasoning
- Supports up to 50 iterations to handle complex tasks
- Has parallel tool execution capability
- Supports dynamic subagent deployment and management
Research Subagents
Research Subagents are specialized agents created by the lead agent to handle specific research tasks. Each subagent:
- Focuses on a specific aspect of the research query
- Uses natural language queries for web search
- Retrieves detailed content from specific URLs
- Reports findings back to the lead agent
- Uses the Gemini Flash model for efficient processing
- Is optimized for focused research tasks (up to 30 iterations)
- Is equipped with web search and content scraping tools
- Has a unique identifier for tracking and coordination
Usage
The system exposes its functionality through two interfaces:
- Model Context Protocol (MCP): The system implements MCP to expose the DeepResearch tool, allowing integration with MCP-compatible clients.
- Standard HTTP API: Also available.
Both interfaces use the same underlying main research agent and provide the same functionality.
Installation and Running
Environment setup: Configure environment variables by copying the example environment file.
Build and run: After the server starts successfully, the corresponding information will be displayed.
Agent Configuration
- Main agent: Gemini Pro model, up to 50 iterations, history compression
- Subagent: Gemini Flash model, up to 30 iterations, focused tools
- Parallel execution: Enabled for both agent types
- Tool registry: Dynamic tool registration and management
Search Configuration
- Search provider: Sonar Search Manager (using Perplexity's Sonar model)
- Model selection: The entire application uses OpenRouter to access different models, including the Sonar by Perplexity model used for search functionality
- Content scraping: Extract content from web pages
- Natural language results: Process search results in a conversational format
Use Cases
- Complex research queries
- Multi-domain investigations
- Coding assistance
- General research tasks
Tech Stack
This implementation is built using the Koog AI Framework, a Kotlin-based framework for building complex AI agent systems. Koog provides:
- Agent management: Core agent lifecycle and execution management
- Tool registry: Dynamic tool registration and execution
- Strategy pattern: Declarative agent behavior definition
- Prompt management: Complex prompt engineering capabilities
- Model integration: Support for multiple LLM providers
Key Dependencies
- Koog Agents Core: ai.koog.agents.core.* - Main agent framework
- Koog Prompts: ai.koog.prompt.dsl.* - Prompt engineering tools
- Ktor: Web server and HTTP client functionality
- Model Context Protocol: MCP integration for external tool access
- OpenRouter: LLM model access and execution
Project Structure (non-final)
- LeadResearchAgent: Main orchestration agent
- ResearchSubagent: Specialized research agent
- ResearchLeadAgentTools: Tools available to the main agent (deployAgent, completeTask)
- ResearchSubagentTools: Tools available to subagents (webSearch, webFetch)
- SonarSearchManager: Search and content scraping implementation
Note: The complete task tool is currently useless.
Limitations and Extension Directions
This project demonstrates multi-agent coordination and can be extended in the following directions:
- Optimize parallel processing
- Manage agent memory to save context window
- Enhance search capabilities
- Integrate more LLM providers
- Functional citation management
- Performance monitoring and analysis
For more details, see Roadmap.md.