Skip to main content
Multi-agent research team that produces structured reports.

Code

"""AG2 (formerly AutoGen) multi-agent research team wrapped with Bindu.

Three specialized agents collaborate under GroupChat with LLM-driven
speaker selection to produce structured research reports. The team is
exposed as a single Bindu agent, callable via A2A protocol.

Architecture:
    User (via Bindu A2A) → handler → AG2 GroupChat
        ├── researcher — gathers information
        ├── analyst   — evaluates findings
        └── writer    — produces the final report
"""

import os
from autogen import ConversableAgent, LLMConfig
from autogen.agentchat import initiate_group_chat
from autogen.agentchat.group.patterns import AutoPattern
from bindu.penguin import bindufy
from dotenv import load_dotenv

load_dotenv()

llm_config = LLMConfig(
    {
        "model": os.getenv("LLM_MODEL", "openai/gpt-4o-mini"),
        "api_key": os.environ.get("OPENROUTER_API_KEY", ""),
        "base_url": "https://openrouter.ai/api/v1",
    }
)

config = {
    "author": "ag2-community",
    "name": "ag2-research-team",
    "description": (
        "A multi-agent research team powered by AG2 (formerly "
        "AutoGen). Three specialists — researcher, analyst, and "
        "writer — collaborate to produce structured reports on "
        "any topic."
    ),
    "deployment": {
        "url": "http://localhost:3773",
        "expose": True,
        "cors_origins": ["http://localhost:5173"],
    },
    "skills": ["skills/question-answering"],
}

def handler(messages: list[dict[str, str]]):
    """Run the AG2 research team and return the final report."""
    if not messages:
        return [{"role": "assistant", "content": "No input provided."}]
    user_input = messages[-1].get("content", "")
    if not user_input:
        return [{"role": "assistant", "content": "Empty message."}]

    # Fresh agents per request to avoid state leakage
    researcher = ConversableAgent(
        name="researcher",
        system_message=(
            "You are a research specialist. Investigate the "
            "given topic thoroughly. Present key facts, data "
            "points, and sources in a structured format."
        ),
        llm_config=llm_config,
    )

    analyst = ConversableAgent(
        name="analyst",
        system_message=(
            "You are an analyst. Review the researcher's "
            "findings. Identify trends, implications, risks, "
            "and opportunities. Be quantitative where possible."
        ),
        llm_config=llm_config,
    )

    writer = ConversableAgent(
        name="writer",
        system_message=(
            "You are a report writer. Once the researcher and "
            "analyst have contributed, synthesize their work "
            "into a structured report with: Executive Summary, "
            "Key Findings, Analysis, and Recommendations. "
            "Keep it under 500 words. End with TERMINATE."
        ),
        llm_config=llm_config,
    )

    user = ConversableAgent(
        name="user", human_input_mode="NEVER"
    )

    pattern = AutoPattern(
        initial_agent=researcher,
        agents=[researcher, analyst, writer],
        user_agent=user,
        group_manager_args={"llm_config": llm_config},
    )

    result, ctx, last = initiate_group_chat(
        pattern=pattern,
        messages=f"Research and produce a report on: {user_input}",
        max_rounds=10,
    )

    # Extract the last substantive message
    for msg in reversed(result.chat_history):
        content = msg.get("content", "")
        if content and "TERMINATE" not in content:
            return [{"role": "assistant", "content": content}]

    return [{"role": "assistant", "content": "Research complete."}]

if __name__ == "__main__":
    bindufy(config, handler)

Skill Configuration

Create skills/research-team-skill/skill.yaml:
# Research Team Skill
# Multi-agent research team powered by AG2 (formerly AutoGen)

id: research-team-skill
name: Research Team Skill
version: 1.0.0
author: ag2-community

description: |
  Multi-agent research team powered by AG2 (formerly AutoGen) that 
  produces comprehensive research reports through collaborative AI agents.

  This skill orchestrates three specialized agents:
  - **Researcher**: Gathers information, facts, and sources
  - **Analyst**: Evaluates findings, identifies trends and implications
  - **Writer**: Synthesizes into structured reports

  The team uses LLM-driven speaker selection to coordinate
  collaboration and deliver structured research outputs on any topic.

  Features:
  - Multi-agent collaboration with dynamic speaker selection
  - Structured report generation (Executive Summary, Key Findings, Analysis, Recommendations)
  - Stateless per-request processing for data privacy
  - Comprehensive research with source attribution
  - Trend analysis and risk assessment

tags:
  - research
  - multi-agent
  - collaboration
  - analysis
  - reporting
  - ag2
  - autogen
  - team-work
  - structured-output

input_modes:
  - text/plain
  - application/json

output_modes:
  - text/plain
  - application/json

examples:
  - "Research and analyze the impact of AI on healthcare"
  - "Produce a report on renewable energy trends"
  - "Analyze the current state of quantum computing"
  - "Research the future of autonomous vehicles"
  - "Generate a report on blockchain adoption in finance"

capabilities_detail:
  multi_agent_research:
    supported: true
    description: "Three-agent collaboration for comprehensive research"
    features:
      - dynamic_speaker_selection
      - role_specialization
      - collaborative_synthesis

  structured_reporting:
    supported: true
    description: "Produces structured reports with standard sections"
    output_structure:
      - executive_summary
      - key_findings
      - analysis
      - recommendations

  source_gathering:
    supported: true
    description: "Research agent gathers facts and sources"
    methodology: "Systematic information collection with verification"

  trend_analysis:
    supported: true
    description: "Analyst agent identifies trends and implications"
    analysis_types:
      - market_trends
      - technological_trends
      - risk_assessment

  report_synthesis:
    supported: true
    description: "Writer agent creates cohesive final reports"
    features:
      - concise_synthesis
      - structured_format
      - action-oriented_recommendations

requirements:
  packages:
    - "ag2[openai]>=0.11.0"
    - "python-dotenv>=1.0.0"
  system:
    - internet_connection
  api_keys:
    - OPENROUTER_API_KEY

performance:
  avg_processing_time_ms: 30000
  max_concurrent_requests: 3
  context_window_tokens: 128000
  scalability: horizontal

assessment:
  keywords:
    - research
    - analyze
    - report
    - investigate
    - study
    - examine
    - multi-agent
    - team
    - collaborate
    - findings
    - analysis
    - trends
    - recommendations

  specializations:
    - domain: research
      confidence_boost: 0.4
    - domain: analysis
      confidence_boost: 0.3
    - domain: reporting
      confidence_boost: 0.3
    - domain: multi-agent
      confidence_boost: 0.5

  anti_patterns:
    - "real-time data"
    - "image generation"
    - "file processing"
    - "database queries"
    - "code execution"
    - "live monitoring"

  complexity_indicators:
    simple:
      - "research"
      - "analyze"
      - "report on"
    medium:
      - "comprehensive analysis"
      - "detailed report"
      - "investigate trends"
    complex:
      - "multi-domain research"
      - "comprehensive study"
      - "cross-disciplinary analysis"

How It Works

Multi-Agent Architecture
  • Three specialized agents collaborate in GroupChat
  • Researcher gathers information and data
  • Analyst evaluates findings and identifies trends
  • Writer synthesizes into structured reports
Agent Roles
  • researcher: Investigates topics thoroughly with facts and sources
  • analyst: Reviews findings, identifies risks and opportunities
  • writer: Creates structured reports with executive summary
Coordination
  • AutoPattern manages agent selection and conversation flow
  • LLM-driven speaker selection for optimal collaboration
  • Fresh agent instances per request prevent state leakage
Report Generation
  • Structured format: Executive Summary, Key Findings, Analysis, Recommendations
  • 500-word limit for concise reports
  • Automatic termination and content extraction

Dependencies

uv init
uv add bindu ag2[openai] python-dotenv

Environment Setup

Create .env file:
OPENROUTER_API_KEY=your_openrouter_api_key_here

Run

uv run ag2-research-team.py
Examples:
  • “Research and analyze the impact of AI on healthcare”
  • “Produce a report on renewable energy trends”
  • “Analyze the current state of quantum computing”

Example API Calls

{
  "jsonrpc": "2.0",
  "method": "message/send",
  "params": {
    "message": {
      "role": "user",
      "kind": "message",
      "messageId": "9f11c870-5616-49ad-b187-d93cbb100001",
      "contextId": "9f11c870-5616-49ad-b187-d93cbb100002",
      "taskId": "9f11c870-5616-49ad-b187-d93cbb100003",
      "parts": [
        {
          "kind": "text",
          "text": "Research and analyze the impact of AI on healthcare"
        }
      ]
    },
     "skillId": "research-team-skill",
    "configuration": {
      "acceptedOutputModes": ["application/json"]
    }
  },
  "id": "9f11c870-5616-49ad-b187-d93cbb100003"
}
{
  "jsonrpc": "2.0",
  "method": "tasks/get",
  "params": {
    "taskId": "9f11c870-5616-49ad-b187-d93cbb100003"
  },
  "id": "9f11c870-5616-49ad-b187-d93cbb100004"
}

Frontend Setup

# Clone the Bindu repository
git clone https://github.com/GetBindu/Bindu

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start frontend development server
npm run dev
Open http://localhost:5173 and try to chat with the AG2 research team