SkillAgentSearch skills...

Multi Agent Reasoning

The Multi-Agent Reasoning framework creates an interactive chatbot where AI agents collaborate via structured reasoning and Swarm Integration for optimal answers. Simulating a team that discusses, debates, and refines responses, it enables complex problem-solving and precise results. Now with Prompt Caching to reduce latency and costs.

Install / Use

npx skills add AdieLaine/multi-agent-reasoning

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Multi-Agent Reasoning with Memory and Swarm Framework

Multi-Agent Reasoning Banner

Table of Contents


Overview

The Multi-Agent Reasoning with Memory and Swarm Framework framework creates an interactive chatbot experience where multiple AI agents collaborate through a structured reasoning process to provide optimal answers. Each agent brings unique perspectives and expertise, and through iterative steps of discussion, verification, critique, and refinement, they converge on a high-quality, accurate response.

Additionally, the system integrates the Swarm Framework for Intelligence to enhance collaboration among agents. Swarm allows agents to coordinate efficiently, leveraging collective intelligence to solve complex tasks.

Users can also chat with individual agents. Agents are aware of each other, including their personalities and quirks, and can answer questions about one another, providing a rich and interactive experience.

Features

  • Multi-Agent Collaboration: Simulates collaborative reasoning among multiple agents.
  • Swarm Framework Integration: Enhances agent coordination and execution.
  • Agent Awareness: Agents are aware of each other, including personalities and capabilities.
  • Direct Agent Chat: Engage in personalized conversations with individual agents.
  • Structured Reasoning Process: Multi-step process including discussion, verification, critique, and refinement.
  • Swarm-Based Reasoning: Dynamic agent handoffs and function execution using Swarm.
  • Iterative Refinement: Improve responses through multiple iterations for enhanced accuracy.
  • Response Blending: Combine refined responses into a single, cohesive answer.
  • User Feedback Loop: Incorporate user feedback for further response refinement.
  • Context Retention Option: Maintain conversation context for more coherent interactions.
  • Customizable Agents: Easily add or modify agents via a JSON configuration file.
  • Parallel Processing: Concurrent agent tasks improve efficiency.
  • Robust Error Handling: Implements retry mechanisms and extensive logging.
  • Token Usage Transparency: Displays detailed token usage information post-response.
  • Prompt Caching: Reduces latency and cost for repeated prompts using OpenAI's caching.

Prerequisites

  • Python 3.10 or higher
  • OpenAI Python Library (compatible with the models used)
  • colorama: For colored console output
  • tiktoken: For accurate token counting
  • Swarm: For agent coordination

Installation

  1. Clone the Repository

    git clone https://github.com/AdieLaine/multi-agent-reasoning.git
    
  2. Navigate to the Project Directory

    cd multi-agent-reasoning
    
  3. Create a Virtual Environment (Optional but Recommended)

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  4. Install Required Packages

    pip install -r requirements.txt
    

    Alternatively, install packages individually:

    pip install openai colorama tiktoken
    
  5. Install Swarm

    pip install git+https://github.com/openai/swarm.git
    

    Refer to Swarm's GitHub repository for detailed installation instructions.

  6. Set Your OpenAI API Key

    Set your API key as an environment variable:

    export OPENAI_API_KEY='your-api-key-here'
    

    On Windows:

    set OPENAI_API_KEY=your-api-key-here
    

    Alternatively, use a .env file or set it directly in your script.

Usage

Execute the main script to start the Multi-Agent Reasoning chatbot:

python reasoning.py

Upon running, you'll see the main menu:

═════════════════════════════════════════════════════════════════════════════════════════════
╔════════════════════════════════════════════════════════════════════════════════════╗
║                        Multi-Agent Reasoning Chatbot                               ║
╚════════════════════════════════════════════════════════════════════════════════════╝
Please select an option:
1. Chat with an agent
2. Use reasoning logic
3. Use Swarm-based reasoning
4. Exit
Enter your choice (1/2/3/4):

Option Descriptions

  1. Chat with an Agent

    • Engage directly with a selected agent.
    • Agents possess unique personalities and can answer questions about themselves and others.
  2. Use Reasoning Logic

    • Initiate a collaborative reasoning process involving multiple agents.
    • Follows structured steps: discussion, verification, critique, refinement, and blending.
  3. Use Swarm-Based Reasoning

    • Utilize the Swarm Framework for Intelligence for dynamic agent coordination.
    • Agents can delegate tasks to specialized agents seamlessly.
  4. Exit

    • Terminate the application.

Models

The system utilizes specific OpenAI models tailored to different functionalities:

  • Reasoning Logic: o1 for advanced reasoning tasks is optimal, you can also use gpt-4o.
    • o1 Model Compatible: o1 is compatible with this current code version, other models may be added in lieu of o1.
  • Chat Interactions: gpt-4o for interactive agent conversations.
  • Swarm Agents: Configurable, defaulting to gpt-4o.

These models support detailed token usage reporting, aiding in monitoring and optimizing performance.

Agents' Reasoning and Chat Process

Chat Mode

Objective: Engage in direct, personalized conversations with a chosen agent.

  • Process:
    • Select an agent from the available list.
    • Interact with the agent while maintaining conversation context.
    • Agents can reference and discuss each other based on their configurations.

Example:

  • User: "Tell me about Agent 74."
  • Agent 47: "Agent 74 is our creative and empathetic counterpart, specializing in imaginative solutions and understanding user emotions."

Agents

Reasoning Logic Mode

Objective: Facilitate a comprehensive reasoning process through multi-agent collaboration.

Steps:

  1. Initial Discussion

    • Each agent generates an independent response to the user's prompt.
    • Ensures diverse perspectives without immediate influence from other agents.
  2. Verification

    • Agents verify the accuracy and validity of their responses.
    • Ensures factual correctness and reliability.
  3. Critiquing

    • Agents critique each other's verified responses.
    • Identifies areas for improvement, omissions, or biases.
  4. Refinement

    • Agents refine their responses based on critiques.
    • Enhances completeness and accuracy.
  5. Response Blending

    • Combines refined responses into a single, cohesive answer.
    • Utilizes the blend_responses function for optimal synthesis.
  6. User Feedback Loop

    • Users provide feedback on the response's helpfulness and accuracy.
    • Allows for further refinement if necessary.
  7. Context Retention

    • Option to retain conversation context for more coherent future interactions.

Swarm Integration

Overview

Swarm Integration enhances the Multi-Agent Reasoning system by enabling dynamic agent coordination and task delegation. Swarm allows agents to collaborate efficiently, leveraging collective intelligence to solve complex tasks and improve responsiveness.

Swarm focuses on making agent coordination and execution lightweight, highly controllable, and easily testable. It achieves this through two primitive abstractions: Agents and Handoffs. An Agent encompasses instructions and tools and can, at any point, choose to hand off a conversation to another Agent.

Swarm Integration

How It Works

  • Swarm Client Initialization

    from swarm import Agent, Swarm
    client = Swarm()
    
  • Agent Initialization

    • Agents are initialized using Swarm, incorporating configurations from agents.json.
    • Each agent has unique instructions and is aware of other agents' capabilities.
  • Conversation Handling

    • Swarm manages conversation flow, agent selection, and function execution.
    • Agents can delegate tasks to specialized agents based on context.

Swarm-Based Reasoning

Objective: Utilize the Swarm Framework for Intelligence to coordinate agents dynamically for efficient collaboration and task delegation.

Steps:

  1. Initialization

    • Load agents from agents.json.
    • Initialize agents with awareness of their counterparts.
  2. Discussion

    • Each agent provides an initial response to the user prompt.
    • Resp

Related Skills

View on GitHub
GitHub Stars185
CategoryCustomer
Updated21d ago
Forks39

Languages

Python

Security Score

100/100

Audited on Jul 18, 2026

No findings