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.
+----------------+
| Orchestrator |
+--------+-------+
|
+---------------------+---------------------+
| | |
v v v
+--------------+ +--------------+ +--------------+
| Researcher | | Planner | | Executor |
| Agent | | Agent | | Agent |
+------+-------+ +------+-------+ +------+-------+
| | |
+---------+---------+---------+---------+
| Shared Memory |
+---------------+
- Agent-based architecture
- Shared memory between agents
- Central orchestration layer
- Easily extensible
- Beginner-friendly codebase
- Foundation for LLM-powered agents
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
Abstract base class that all agents inherit from.
Responsibilities:
- Common agent interface
- Standardized execution method
Responsible for gathering information about a task.
Example:
researcher.run("Build a trading bot")Output:
[Research] Found information about: Build a trading bot
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
Responsible for executing the generated plan.
Example:
executor.run("Build a trading bot")Output:
[Execution] Completed task: Build a trading bot
Stores information generated by agents.
Example:
memory.store("research", result)
memory.retrieve("research")Coordinates communication between agents.
Execution flow:
- Research phase
- Planning phase
- Execution phase
- Store results in memory
- Return final output
unzip multi_agent_system.zip
cd multi_agent_systemLinux / Mac:
python3 -m venv venv
source venv/bin/activateWindows:
python -m venv venv
venv\Scripts\activatepip install -r requirements.txtpython main.pyExpected 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': ...
}
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
)Connect agents to:
- OpenAI GPT
- Anthropic Claude
- Gemini
- Local models (Ollama)
Example:
response = llm.invoke(prompt)Agents can access:
- Web Search
- Databases
- APIs
- File Systems
- Trading Platforms
Replace in-memory storage with:
- SQLite
- PostgreSQL
- Redis
- Vector Databases
Add:
- Message queues
- Event buses
- Publish / Subscribe systems
Run agents concurrently:
asyncio.gather(
researcher.run(task),
planner.run(task),
)Agents:
- MarketDataAgent
- StrategyAgent
- RiskManagerAgent
- ExecutionAgent
Agents:
- ClassificationAgent
- KnowledgeAgent
- ResponseAgent
Agents:
- RequirementsAgent
- DesignAgent
- CodingAgent
- TestingAgent
This project follows:
- Single Responsibility Principle
- Separation of Concerns
- Modular Architecture
- Extensibility
- Maintainability
MIT License
Feel free to modify and extend this project for personal or commercial use.
Recommended upgrades:
- Add OpenAI integration
- Add agent-to-agent messaging
- Add tool calling
- Add persistent memory
- Add asynchronous execution
- Add REST API interface
- Add Docker support
- Add monitoring and logging
This starter project is intentionally simple and serves as a foundation for building production-grade multi-agent systems.