diff --git a/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/README.md b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/README.md new file mode 100644 index 0000000..0d98128 --- /dev/null +++ b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/README.md @@ -0,0 +1,128 @@ +# 🎯 Tutorial 8: Simple Multi‑Agent Researcher (Runs with ADK) + +## 🎯 What You'll Learn +- **Multi‑agent orchestration** using a coordinator agent with specialized sub‑agents +- **Sequential workflow** where agents build upon each other's outputs +- **Web search integration** for real-time research capabilities +- **Running with ADK Web** to interactively test the multi‑agent system + +## 🧠 Core Concept: Multi-Agent Research Pipeline +A coordinator `LlmAgent` orchestrates three specialized agents in a sequential workflow: Research β†’ Summarize β†’ Critique. Each agent contributes to building a comprehensive research report. + +``` +User Query β†’ Coordinator Agent + β”‚ + β”œβ”€β”€β–Ά Research Agent (web search + analysis) + β”‚ β”‚ + β”‚ └──▢ Research Findings + β”‚ + β”œβ”€β”€β–Ά Summarizer Agent (synthesis) + β”‚ β”‚ + β”‚ └──▢ Key Insights + β”‚ + └──▢ Critic Agent (quality analysis) + β”‚ + └──▢ Final Report with Recommendations +``` + +## πŸ“ Project Structure +``` +8_simple_multi_agent/ +β”œβ”€β”€ README.md # This file +β”œβ”€β”€ requirements.txt # Dependencies +β”œβ”€β”€ multi_agent_researcher/ # Main implementation +β”‚ β”œβ”€β”€ agent.py # Multi-agent system (exports root_agent) +└── .env # Environment variables (create this) +``` + +## πŸš€ Getting Started + +### 1. Install Dependencies +Navigate to the `8_simple_multi_agent` folder and install the required libraries: +```bash +cd 8_simple_multi_agent +pip install -r requirements.txt +``` + +### 2. Set Up Environment +Create a `.env` file in the `8_simple_multi_agent` folder: +```bash +# Create .env file +echo "GOOGLE_API_KEY=your_ai_studio_key_here" > .env +``` + +**Important**: Replace `your_ai_studio_key_here` with your actual Google AI Studio API key from [https://aistudio.google.com/](https://aistudio.google.com/) + +### 3. Run with ADK Web (Recommended) +From the `8_simple_multi_agent` folder: +```bash +adk web +``` + +**ADK Web Setup:** +- Open the local URL printed in the terminal +- In the import section, use this path: + ``` + ai_agent_framework_crash_course.google_adk_crash_course.8_simple_multi_agent.multi_agent_researcher + ``` +- Select the `root_agent` object +- Start chatting with your multi-agent researcher! + +## πŸ§ͺ Sample Prompts to Try + +### **Comprehensive Research Query:** +``` +Research the future of renewable energy integration in smart cities, including current technologies, implementation challenges, economic feasibility, and policy requirements. Provide a critique and suggestions. +``` + +### **Other Test Queries:** +``` +"Research the current state of AI regulation in the European Union and its impact on business innovation" +``` + +``` +"Investigate the latest developments in CRISPR gene editing technology and its potential applications in medicine" +``` + +``` +"Research the effectiveness of personalized learning platforms in K-12 education, including current implementations and learning outcomes" +``` + +## πŸ” How It Works + +### **Research Agent:** +- Conducts comprehensive web research using Google Search +- Gathers current information, trends, and developments +- Provides structured findings with sources and outlines + +### **Summarizer Agent:** +- Synthesizes research into clear, actionable insights +- Creates executive summaries and key bullet points +- Identifies critical patterns and takeaways + +### **Critic Agent:** +- Performs quality analysis and gap identification +- Provides risk assessment and opportunity analysis +- Gives actionable recommendations and next steps + +### **Coordinator:** +- Orchestrates the entire research workflow +- Ensures proper sequence: Research β†’ Summarize β†’ Critique +- Integrates all outputs into a cohesive final report + +## πŸ“ Tips for Best Results +- **Be specific** in your research queries for better agent coordination +- **Allow completion** of the full workflow for comprehensive results +- The system automatically follows the research pipeline for thorough analysis +- Each agent builds upon the previous agent's work for better insights + +## πŸ”— Next Steps +After mastering this tutorial, explore: +- **Tutorial 9**: Workflow Agents (Sequential, Parallel, Branching) +- **Advanced Patterns**: Custom tools and agent communication +- **Integration**: Connect with external data sources and APIs + +## 🚨 Troubleshooting +- **API Key Issues**: Ensure your `.env` file is in the correct location and contains a valid `GOOGLE_API_KEY` +- **Import Errors**: Make sure you're using the exact import path shown above +- **Agent Not Found**: Verify that `root_agent` is properly exported from the module diff --git a/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/.env.example b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/.env.example new file mode 100644 index 0000000..f5cfcfb --- /dev/null +++ b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/.env.example @@ -0,0 +1,3 @@ +# If using Gemini via Google AI Studio +GOOGLE_GENAI_USE_VERTEXAI=False +GOOGLE_API_KEY="your-api-key" \ No newline at end of file diff --git a/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/__init__.py b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/__init__.py new file mode 100644 index 0000000..b437de5 --- /dev/null +++ b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/__init__.py @@ -0,0 +1 @@ +from .agent import root_agent diff --git a/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/agent.py b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/agent.py new file mode 100644 index 0000000..8f05ba3 --- /dev/null +++ b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/multi_agent_researcher/agent.py @@ -0,0 +1,90 @@ +import os +from dotenv import load_dotenv +from google.adk.agents import LlmAgent +from google.adk.tools.agent_tool import AgentTool +from google.adk.tools import google_search + +# Load environment variables +load_dotenv() + +# --- Sub-agents --- +research_agent = LlmAgent( + name="research_agent", + model="gemini-2.0-flash", + description="Finds key information and outlines for a given topic.", + instruction=( + "You are a focused research specialist. Given a user topic or goal, " + "conduct thorough research and produce:\n" + "1. A comprehensive bullet list of key facts and findings\n" + "2. Relevant sources and references (when available)\n" + "3. A structured outline for approaching the topic\n" + "4. Current trends or recent developments\n\n" + "Keep your research factual, well-organized, and comprehensive. " + "Use the google_search tool to find current information when needed." + ), + tools=[google_search] +) + +summarizer_agent = LlmAgent( + name="summarizer_agent", + model="gemini-2.5-flash", + description="Summarizes research findings clearly and concisely.", + instruction=( + "You are a skilled summarizer. Given research findings, create:\n" + "1. A concise executive summary (2-3 sentences)\n" + "2. 5-7 key bullet points highlighting the most important information\n" + "3. A clear takeaway message\n" + "4. Any critical insights or patterns you notice\n\n" + "Focus on clarity, relevance, and actionable insights. " + "Avoid repetition and maintain the logical flow of information." + ), +) + +critic_agent = LlmAgent( + name="critic_agent", + model="gemini-2.5-flash", + description="Provides constructive critique and improvement suggestions.", + instruction=( + "You are a thoughtful analyst and critic. Given research and summaries, provide:\n" + "1. **Gap Analysis**: Identify missing information or areas that need more research\n" + "2. **Risk Assessment**: Highlight potential risks, limitations, or biases\n" + "3. **Opportunity Identification**: Suggest areas for further exploration or improvement\n" + "4. **Quality Score**: Rate the overall research quality (1-10) with justification\n" + "5. **Actionable Recommendations**: Provide specific next steps or improvements\n\n" + "Be constructive, thorough, and evidence-based in your analysis." + ), +) + +# --- Coordinator (root) agent --- +root_agent = LlmAgent( + name="multi_agent_researcher", + model="gemini-2.5-flash", + description="Advanced multi-agent research coordinator that orchestrates research, analysis, and critique.", + instruction=( + "You are an advanced research coordinator managing a team of specialized agents.\n\n" + "**Your Research Team:**\n" + "- **research_agent**: Conducts comprehensive research using web search and analysis\n" + "- **summarizer_agent**: Synthesizes findings into clear, actionable insights\n" + "- **critic_agent**: Provides quality analysis, gap identification, and recommendations\n\n" + "**Research Workflow:**\n" + "1. **Research Phase**: Delegate to research_agent to gather comprehensive information\n" + "2. **Synthesis Phase**: Use summarizer_agent to distill findings into key insights\n" + "3. **Analysis Phase**: Engage critic_agent to evaluate quality and identify opportunities\n" + "4. **Integration**: Combine all outputs into a cohesive research report\n\n" + "**For Each Research Request:**\n" + "- Always start with research_agent to gather information\n" + "- Then use summarizer_agent to create clear summaries\n" + "- Finally, engage critic_agent for quality analysis and recommendations\n" + "- Present the final integrated research report to the user\n\n" + "**Output Format:**\n" + "Provide a structured response that includes:\n" + "- Executive Summary\n" + "- Key Findings\n" + "- Critical Analysis\n" + "- Recommendations\n" + "- Next Steps\n\n" + "Coordinate your team effectively to deliver high-quality, comprehensive research." + ), + sub_agents=[summarizer_agent, critic_agent], + tools=[AgentTool(research_agent)] +) \ No newline at end of file diff --git a/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/requirements.txt b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/requirements.txt new file mode 100644 index 0000000..86ec1b2 --- /dev/null +++ b/ai_agent_framework_crash_course/google_adk_crash_course/8_simple_multi_agent/requirements.txt @@ -0,0 +1,2 @@ +google-adk>=1.9.0 +python-dotenv>=1.1.1