Skip to content

nssanta/Multi-Agent-Router

Repository files navigation

πŸ€– Multi-Agent AI Router

Python 3.9+ TypeScript Docker License: MIT

Modular AI agent platform with multi-provider LLM support.

πŸ“š This is a demo project for learning and exploration purposes.

πŸ‡·πŸ‡Ί Русская вСрсия


🎯 What Makes It Cool

Feature Description
πŸ”Œ Plug & Play LLMs Switch between Gemini, OpenRouter, or any OpenAI-compatible API
🧩 Modular Agents Each agent is independent β€” add your own in minutes
πŸ› οΈ Real Tool Execution Agents don't just chat β€” they do things: search, code, analyze
πŸ“Š Live Crypto Data Binance API integration with real-time prices, orderbook, trades
🐳 Docker Sandbox Code execution in isolated containers β€” safe and reproducible
⚑ Native Tool Calling Gemini 2.5 Pro uses native function calling for reliable execution

πŸ€– Agents

πŸ” Dialog Agent

Intelligent conversational agent with web capabilities

  • Smart Search β€” Multi-source web search with result aggregation
  • Page Reading β€” Extract and summarize content from any URL
  • Context Awareness β€” Maintains conversation history and session state

🧠 Coder Agent

Full-featured coding assistant that actually executes code

Coder Agent

  • File Operations β€” Create, read, list files in isolated workspace
  • Code Execution β€” Run Python in sandboxed Docker environment
  • Multi-File Projects β€” Import between files, build complete projects
  • Native Tool Calling β€” Gemini 2.5 Pro uses native function calling
  • Tool Support Indicator β€” βœ…/⚠️ shows which models support native tools

Example:

User: Calculate fibonacci sequence up to 100

Agent: I'll create and run a Python script for you.
[Creates fibonacci.py β†’ Executes β†’ Returns result]

Output: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

πŸ“Š Crypto Analyst Agent v2.0

Professional cryptocurrency analyzer with real-time Binance data

Crypto Analyst

Real-time data from Binance API:

  • πŸ’° Price & Candles β€” Current price, 24h change, multi-timeframe data
  • πŸ“ˆ 12 Technical Indicators β€” RSI, MACD, EMA, Bollinger, StochRSI, ADX, ATR, VWAP, OBV, Ichimoku, SuperTrend, CMF
  • πŸ“Š Orderbook Analysis β€” Deltas at 7 levels (1.5%, 3%, 5%, 15%, 30%, 60%, 90%)
  • πŸ”„ Trade Flow β€” Buy/sell pressure, whale activity, trade velocity, size distribution
  • πŸ“‰ Futures Data β€” Funding Rate, Open Interest, Long/Short Ratio
  • 🎯 Smart Money Concepts β€” FVG, Order Blocks, Market Structure (HH/HL/LL/LH), Liquidity Zones
  • πŸ—“οΈ Multi-Timeframe β€” Short/Medium/Long-term analysis (3 horizons)
  • πŸ“Š Volume Analysis β€” Volume Delta, Relative Volume, Volume Profile (POC, VAH, VAL)
  • 😨 Market Context β€” Fear & Greed Index, total market cap

Modular Queries:

"analyze BTC"      β†’ Full analysis
"indicators ETH"  β†’ Technical indicators only
"orderbook SOL"   β†’ Orderbook analysis
"smc BTC"         β†’ Smart Money Concepts
"sentiment ETH"   β†’ Fear&Greed + Funding Rate
"volume SOL"      β†’ Volume analysis
"mtf BTC"         β†’ Multi-timeframe

Example Analysis:

πŸ“‰ BTC/USDT Analysis | 2025-12-07

Price: $89,690.73 (-0.03% 24h)

MTF Signal: Bearish (Short: bullish, Medium: mixed, Long: bearish)

Order Flow: 82.6% buys β€” BUT whales selling (6 whale sells, 0 buys)

Smart Money: Downtrend structure (2 LH, 2 LL), 3 bearish FVG targets

Futures: L/S Ratio 2.17 (longs overloaded β€” squeeze risk)

Verdict: SELL β€” Retail buying into whale distribution


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend  │────▢│   FastAPI    │────▢│   LLM Provider  β”‚
β”‚   (React)   β”‚     β”‚   (routes)   β”‚     β”‚ Gemini/OpenRouterβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                    β–Ό             β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Agent  β”‚   β”‚ Session β”‚
              β”‚ Dialog/ β”‚   β”‚ Manager β”‚
              β”‚ Coder/  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ Crypto  β”‚
              β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                   β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Tools  β”‚
              β”‚ search/ β”‚
              β”‚ files/  β”‚
              β”‚ code/   β”‚
              β”‚ crypto  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Security

This project implements multiple layers of security for code execution:

Layer Protection
🐳 Sandbox Container Code runs in isolated Docker container with no network access
πŸ“ Path Validation All file operations restricted to session workspace
⏱️ Resource Limits CPU, memory, and timeout constraints
πŸ‘€ Non-root User Sandbox runs as unprivileged user

⚠️ Disclaimer: This is a demonstration project. For production use, consider additional hardening (gVisor, Firecracker, etc.)

⚠️ Known Limitations

Issue Description Status
Sandbox Fallback If sandbox is unavailable, code may execute locally ⚠️ TODO: Add explicit flag
Context Window Long conversations may exceed token limits (no RAG) Demo scope
Regex JSON Fallback Legacy fallback for non-native tool calling models Use Gemini 2.5 Pro

πŸš€ Quick Start

git clone https://github.com/nssanta/Multi-Agent-Router.git
cd Multi-Agent-Router
cp .env.example .env
# Add your API keys to .env
docker compose up --build

Open: http://localhost:3000


βš™οΈ Configuration

# Required
GEMINI_API_KEY=your_gemini_key
OPENROUTER_API_KEY=your_openrouter_key

# Optional
LLM_PROVIDER=gemini          # or openrouter
LLM_MODEL=gemini-2.5-pro     # default model

πŸ”§ Extending the System

Add a New Agent

# backend/agents/my_agent/agent.py
def create_my_agent(llm_provider, session_path):
    return Agent(
        name="my_agent",
        llm_provider=llm_provider,
        instruction="Your custom prompt",
        tool_definitions=[...],
    )

Add a New Tool

# backend/tools/my_tool.py
def my_tool(param: str) -> str:
    """Tool description for LLM"""
    return f"Result: {param}"

πŸ“ Project Structure

backend/
β”œβ”€β”€ agents/           # Dialog, Coder, Crypto agents
β”‚   β”œβ”€β”€ dialog/       # Conversational agent
β”‚   β”œβ”€β”€ coder/        # Code execution agent
β”‚   └── crypto/       # Cryptocurrency analyst
β”œβ”€β”€ api/              # FastAPI routes
β”œβ”€β”€ core/             # LLM providers, sessions, executor
└── tools/            # Agent tools
    β”œβ”€β”€ web/          # Search, page reader
    └── crypto/       # Binance API, indicators

frontend/
β”œβ”€β”€ src/components/   # React components
└── src/services/     # API client

Full technical documentation: TECHNICAL_DOCS.md


πŸ“„ License

MIT

About

A modular multi-agent framework and UI for orchestration between local and remote LLMs (Gemini, OpenRouter) with advanced tool calling capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors