Skip to content

Latest commit

 

History

History
338 lines (239 loc) · 9.66 KB

File metadata and controls

338 lines (239 loc) · 9.66 KB
title Lesson 8: Multi-Agent Systems
subtitle AI Agents for Beginners
theme seriph
transition slide-left
class text-center
highlighter shiki
lineNumbers false
drawings
persist
download true
exportFilename 08-multi-agent-slides
layout cover
info ## AI Agents for Beginners Lesson 8: Multi-Agent Systems Learn about creating systems with multiple AI agents that can collaborate or delegate tasks.

AI Agents for Beginners

Lesson 8: Multi-Agent Systems Learn about creating systems with multiple AI agents that can collaborate or delegate tasks.


layout: default


layout: intro

Lesson 8: Multi-Agent Systems

Welcome to Lesson 8! In this lesson, we'll explore the fascinating world of Multi-Agent Systems.

  • We'll learn how to create systems where multiple AI agents can collaborate, delegate tasks, and work together to achieve common goals.
  • We'll also look at different patterns and architectures for designing effective multi-agent systems.

layout: default

What are Multi-Agent Systems?

A Multi-Agent System (MAS) is a system composed of multiple interacting intelligent agents. These agents can be:

  • Cooperative: Working together towards a shared goal.
  • Competitive: Pursuing individual goals that may conflict.
  • Self-interested: Focused on their own objectives.

In this lesson, we'll focus on cooperative multi-agent systems.


layout: two-cols

Why Use Multi-Agent Systems?

  • Modularity: Break down complex problems into smaller, manageable tasks for individual agents.
  • Scalability: Easily add more agents to handle increased workload or complexity.
  • Robustness: The system can continue to function even if some agents fail.
  • Specialization: Different agents can be designed with specific expertise.
  • Parallelism: Agents can work on different tasks concurrently.

::right::

Multi-Agent Collaboration

Conceptual representation of agents collaborating.


layout: default

Key Concepts in Multi-Agent Systems

  • Agent Communication Language (ACL): A standardized language for agents to exchange messages (e.g., FIPA ACL, KQML).
  • Ontology: A shared understanding of the domain, defining terms and relationships.
  • Coordination Mechanisms: How agents synchronize their actions and avoid conflicts (e.g., negotiation, voting, auction).
  • Task Allocation: How tasks are distributed among agents.
  • Team Formation: How groups of agents are formed to achieve specific goals.

layout: section

Designing Multi-Agent Systems


layout: default

Common Architectures

There are several common architectures for multi-agent systems:

  1. Hierarchical: Agents are organized in a tree-like structure with clear lines of command.
    • Example: A manager agent delegates tasks to worker agents.
  2. Federated: A collection of autonomous systems that collaborate.
    • Example: Different organizations' agent systems sharing information.
  3. Blackboard: Agents share information through a common data repository (the blackboard).
    • Example: Agents read and write partial solutions to a shared space.
  4. Peer-to-Peer: Agents interact directly with each other without a central controller.
    • Example: A network of agents negotiating resource allocation.

layout: default

Hierarchical Architecture

In a hierarchical architecture:

  • A "manager" or "coordinator" agent sits at the top.
  • This agent breaks down a complex goal into sub-tasks.
  • Sub-tasks are delegated to specialized "worker" agents.
  • Worker agents might further delegate to other agents or execute the task.
  • Communication typically flows up and down the hierarchy.

Pros: Clear control flow, easier to manage.

Cons: Single point of failure at higher levels, can be less flexible.


layout: default

Example: Travel Planning Multi-Agent System

This system could use a hierarchical or blackboard architecture.

Let's consider a travel planning system with multiple agents:

  • User Interface Agent: Interacts with the user to get travel preferences (destination, dates, budget).
  • Flight Booking Agent: Searches for and books flights.
  • Hotel Booking Agent: Finds and reserves accommodations.
  • Activity Planning Agent: Suggests and books local tours and activities.
  • Coordinator Agent: Receives user request from UI agent, delegates tasks to specialized agents, and aggregates results.

layout: section

Implementing a Multi-Agent System with Semantic Kernel


layout: default

Using Semantic Kernel for Multi-Agent Systems

Semantic Kernel can be used to build individual agents, and then you can orchestrate their interactions.

  • Each agent can be a Kernel instance with its own set of plugins (skills) and memory.
  • You can define functions for inter-agent communication.
  • A "main" orchestrator or another agent can manage the flow of information and tasks between agents.

Let's look at a simplified example.


layout: default

Example Scenario: Research and Summarize

Goal: Research a topic and provide a summary.

Agents:

  1. Research Agent:
    • Skill: Search the web for information on a given topic.
    • Input: Topic
    • Output: List of relevant articles/sources.
  2. Summarization Agent:
    • Skill: Summarize a given text.
    • Input: Text (or list of texts)
    • Output: Concise summary.
  3. Orchestrator Agent (or main application logic):
    • Takes the user's topic.
    • Invokes the Research Agent.
    • Passes the research results to the Summarization Agent.
    • Presents the final summary to the user.

layout: default

Code Snippet: Conceptual Orchestration

The following C# snippet illustrates the conceptual flow. (Note: This is a simplified representation. Actual implementation would involve more detailed Semantic Kernel setup for each agent.)

// Conceptual C# Code for Multi-Agent Orchestration
// (Full code in the lesson's code_samples directory)

public class Orchestrator
{
    private ResearchAgent researchAgent;
    private SummarizationAgent summarizationAgent;

    public Orchestrator()
    {
        // Initialize agents (each with their own Kernel, plugins, etc.)
        this.researchAgent = new ResearchAgent(...);
        this.summarizationAgent = new SummarizationAgent(...);
    }

    public async Task<string> ResearchAndSummarizeTopic(string topic)
    {
        // 1. Research Agent gathers information
        //var researchResults = await this.researchAgent.Search(topic);

        // 2. Summarization Agent processes the results
        //var summary = await this.summarizationAgent.Summarize(researchResults);
        
        // return summary;
        Console.WriteLine($"Orchestrator: Researching and summarizing '{topic}'.");
        Console.WriteLine("Orchestrator: Invoking Research Agent...");
        // Simulate research agent's work
        var researchResults = $"Article 1 about {topic}, Article 2 about {topic}, Data about {topic}."; 
        Console.WriteLine($"Research Agent: Found: {researchResults}");

        Console.WriteLine("Orchestrator: Invoking Summarization Agent...");
        // Simulate summarization agent's work
        var summary = $"This is a concise summary about {topic} based on the research.";
        Console.WriteLine($"Summarization Agent: Summary: {summary}");

        return summary;
    }
}

// To run this:
var orchestrator = new Orchestrator();
string topic = "the future of AI";
string summary = await orchestrator.ResearchAndSummarizeTopic(topic);
Console.WriteLine($"
Final Summary for '{topic}':
{summary}");

For the complete, runnable code, please refer to the `code_samples` directory for this lesson in the main repository.

layout: default

Challenges in Multi-Agent Systems

  • Communication Overhead: Agents need to exchange a lot of messages.
  • Credit Assignment: Determining which agent contributed to a success or failure.
  • Maintaining Coherence: Ensuring agents work towards a common goal without conflicting actions.
  • Scalability: Managing a large number of agents can be complex.
  • Security and Trust: Ensuring agents are trustworthy and communication is secure.

layout: end

Next Steps

Congratulations on completing Lesson 8!

  • You've learned about the fundamentals of multi-agent systems, their benefits, common architectures, and how you might approach building them using tools like Semantic Kernel.
  • Explore the code_samples for this lesson to see a more concrete, albeit simplified, implementation.
  • Think about how you could apply multi-agent concepts to problems you're interested in solving.
In the next lesson, we'll dive into **Metacognition and Self-Correction in AI Agents**.

Proceed to Lesson 9: Metacognition

Return to Main Course Page


class: end

Thank You!

Connect with the community and keep learning.