Skip to content

hieu-is-coding/orchestration_agent_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent Workflow: Research → Write → Review

This project implements a 3-sub-agent workflow for research and report writing using LlamaIndex and Google Gemini AI.

🏗️ Architecture

The workflow consists of three specialized agents that work together:

1. 🔍 ResearchAgent

  • Purpose: Searches for information on the web and records research notes
  • Tools:
    • search_web: Performs Google searches for relevant information
    • record_notes: Saves research findings with titles
  • Output: Research notes stored in the workflow state

2. ✍️ WriteAgent

  • Purpose: Creates professional reports based on research notes
  • Tools:
    • write_report: Generates Markdown-formatted reports
  • Output: Report content stored in the workflow state

3. 📋 ReviewAgent

  • Purpose: Evaluates report quality and provides feedback
  • Tools:
    • review_report: Records evaluation and feedback
  • Output: Review feedback stored in the workflow state

🚀 Workflow Process

User Request → ResearchAgent → WriteAgent → ReviewAgent → Final Response
     ↓              ↓              ↓              ↓
  Orchestrator   Web Search    Report Writing   Quality Review

📁 File Structure

multi-agent/
├── config.py          # Agent configurations and tool definitions
├── workflow.py        # Main workflow orchestration logic
├── main.py           # Complete workflow example
├── simple_test.py    # Simple test script
├── test_workflow.py  # Setup verification script
├── requirements.txt  # Python dependencies
└── README.md         # This file

🛠️ Setup

  1. Install Dependencies

    pip install -r requirements.txt
  2. Set Environment Variables Create a .env file in the project root:

    GOOGLE_API_KEY=your_google_api_key_here
    
  3. Test Setup

    python test_workflow.py
  4. Run Simple Test

    python simple_test.py
  5. Run Complete Example

    python main.py

📝 Usage Example

from config import research_agent_config, write_agent_config, review_agent_config
from workflow import ConciergeAgent
from llama_index.llms.google_genai import GoogleGenAI

# Initialize components
llm = GoogleGenAI(model="gemini-2.0-flash", temperature=0.3)
workflow = ConciergeAgent()

# Run workflow
handler = workflow.run(
    agent_configs=[research_agent_config, write_agent_config, review_agent_config],
    user_msg="Viết báo cáo về xu hướng AI 2024",
    chat_history=[],
    initial_state={
        "research_notes": {},
        "report_content": "",
        "review": "",
    },
    llm=llm,
)

# Get results
result = await handler
print(result["response"])

🔧 Configuration

Agent Configuration

Each agent is configured in config.py with:

  • Name: Agent identifier
  • Description: What the agent does
  • System Prompt: Instructions for the agent
  • Tools: Available functions the agent can use
  • Human Confirmation: Tools requiring approval

State Management

The workflow maintains state across agents:

  • research_notes: Dictionary of research findings
  • report_content: Generated report text
  • review: Evaluation feedback

🎯 Example Scenarios

  1. Research Report: "Viết báo cáo về xu hướng AI 2024"
  2. Update Report: "Cập nhật báo cáo với thông tin mới nhất về AI 2025"
  3. Topic Research: "Nghiên cứu về blockchain technology"

🔄 Agent Transfers

Agents can transfer control to other agents using the request_transfer() tool. The orchestrator decides which agent to activate next based on:

  • Current workflow state
  • User request
  • Agent capabilities

📊 Monitoring

The workflow provides real-time progress updates:

  • Tool execution status
  • Agent transfers
  • State changes
  • Error handling

🚨 Troubleshooting

Common Issues

  1. API Key Missing

    ❌ Please set your GOOGLE_API_KEY in the .env file
    

    Solution: Create a .env file with your Google API key

  2. Import Errors

    ModuleNotFoundError: No module named 'llama_index'
    

    Solution: Install dependencies with pip install -r requirements.txt

  3. Tool Execution Issues

    Encountered error in tool call
    

    Solution: Check that all tools are properly defined in config.py

  4. State Not Updating

    Research Notes: 0 items
    

    Solution: Ensure tools are being called and approved by the workflow

Debug Mode

To enable verbose logging, set verbose=True when creating the workflow:

workflow = ConciergeAgent(verbose=True)

🔮 Current Status

Working Features:

  • 3 sub-agent workflow architecture
  • Agent orchestration and transfers
  • Tool execution and approval system
  • State management across agents
  • Progress monitoring and logging

🔄 In Development:

  • Real Google Search integration (currently using mock data)
  • Persistent state storage
  • Enhanced error handling
  • Web UI interface

🔮 Future Enhancements

  • Add real Google Search API integration
  • Implement agent memory persistence
  • Add web UI for interaction
  • Support for different report formats
  • Integration with external data sources
  • Add more specialized agents (e.g., Data Analysis Agent)

📞 Support

For issues or questions:

  1. Check the troubleshooting section above
  2. Verify your Google API key is set correctly
  3. Ensure all dependencies are installed
  4. Run the test scripts to verify setup

🎉 Success Indicators

When the workflow is working correctly, you should see:

  • Progress messages with emojis (📢, 🔧, ✅)
  • Tool execution confirmations
  • Agent transfer notifications
  • Final response with state information
  • Non-zero values for research notes, report content, and review

About

Testing orchestration for hierarchical multi-agent architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors