Skip to content

imbhavaniprasad/multi_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent System in Python

A simple and extensible multi-agent architecture built in Python.

This project demonstrates how multiple specialized agents can collaborate through a central orchestrator and shared memory to solve tasks.


Architecture

                    +----------------+
                    |   Orchestrator |
                    +--------+-------+
                             |
       +---------------------+---------------------+
       |                     |                     |
       v                     v                     v

+--------------+    +--------------+    +--------------+
| Researcher   |    | Planner      |    | Executor     |
| Agent        |    | Agent        |    | Agent        |
+------+-------+    +------+-------+    +------+-------+
       |                   |                   |
       +---------+---------+---------+---------+
                 | Shared Memory |
                 +---------------+

Features

  • Agent-based architecture
  • Shared memory between agents
  • Central orchestration layer
  • Easily extensible
  • Beginner-friendly codebase
  • Foundation for LLM-powered agents

Project Structure

multi_agent_system/
│
├── agents/
│   ├── base_agent.py
│   ├── researcher_agent.py
│   ├── planner_agent.py
│   └── executor_agent.py
│
├── orchestrator/
│   └── orchestrator.py
│
├── memory/
│   └── shared_memory.py
│
├── tools/
│
├── config/
│
├── main.py
├── requirements.txt
└── README.md

Components

BaseAgent

Abstract base class that all agents inherit from.

Responsibilities:

  • Common agent interface
  • Standardized execution method

ResearcherAgent

Responsible for gathering information about a task.

Example:

researcher.run("Build a trading bot")

Output:

[Research] Found information about: Build a trading bot

PlannerAgent

Responsible for creating a plan based on the task.

Example:

planner.run("Build a trading bot")

Output:

[Plan] Steps to solve: Build a trading bot

ExecutorAgent

Responsible for executing the generated plan.

Example:

executor.run("Build a trading bot")

Output:

[Execution] Completed task: Build a trading bot

SharedMemory

Stores information generated by agents.

Example:

memory.store("research", result)
memory.retrieve("research")

Orchestrator

Coordinates communication between agents.

Execution flow:

  1. Research phase
  2. Planning phase
  3. Execution phase
  4. Store results in memory
  5. Return final output

Installation

1. Clone or Extract

unzip multi_agent_system.zip
cd multi_agent_system

2. Create Virtual Environment

Linux / Mac:

python3 -m venv venv
source venv/bin/activate

Windows:

python -m venv venv
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

Running the Project

python main.py

Expected output:

Final Output:

research: [Research] Found information about: Build a trading bot using EMA strategy

plan: [Plan] Steps to solve: Build a trading bot using EMA strategy

execution: [Execution] Completed task: Build a trading bot using EMA strategy

memory: {
    'research': ...,
    'plan': ...,
    'execution': ...
}

Adding a New Agent

Example: RiskManagerAgent

Create:

# agents/risk_manager_agent.py

from agents.base_agent import BaseAgent

class RiskManagerAgent(BaseAgent):

    def run(self, task):
        return f"Risk analysis for: {task}"

Register in orchestrator:

from agents.risk_manager_agent import RiskManagerAgent

self.risk_manager = RiskManagerAgent(
    "RiskManager",
    self.memory
)

Future Enhancements

LLM Integration

Connect agents to:

  • OpenAI GPT
  • Anthropic Claude
  • Gemini
  • Local models (Ollama)

Example:

response = llm.invoke(prompt)

Tool Usage

Agents can access:

  • Web Search
  • Databases
  • APIs
  • File Systems
  • Trading Platforms

Persistent Memory

Replace in-memory storage with:

  • SQLite
  • PostgreSQL
  • Redis
  • Vector Databases

Agent Communication

Add:

  • Message queues
  • Event buses
  • Publish / Subscribe systems

Async Execution

Run agents concurrently:

asyncio.gather(
    researcher.run(task),
    planner.run(task),
)

Example Use Cases

Trading Systems

Agents:

  • MarketDataAgent
  • StrategyAgent
  • RiskManagerAgent
  • ExecutionAgent

Customer Support

Agents:

  • ClassificationAgent
  • KnowledgeAgent
  • ResponseAgent

Software Development

Agents:

  • RequirementsAgent
  • DesignAgent
  • CodingAgent
  • TestingAgent

Design Principles

This project follows:

  • Single Responsibility Principle
  • Separation of Concerns
  • Modular Architecture
  • Extensibility
  • Maintainability

License

MIT License

Feel free to modify and extend this project for personal or commercial use.


Next Steps

Recommended upgrades:

  1. Add OpenAI integration
  2. Add agent-to-agent messaging
  3. Add tool calling
  4. Add persistent memory
  5. Add asynchronous execution
  6. Add REST API interface
  7. Add Docker support
  8. Add monitoring and logging

This starter project is intentionally simple and serves as a foundation for building production-grade multi-agent systems.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages