A comprehensive framework for building, deploying, and orchestrating intelligent AI agents that can communicate with each other in real-time. Combines gRPC for high-performance agent-to-agent communication with a REST API layer and a modern Next.js dashboard for monitoring and interaction.
β οΈ Early Development Stage
This project is currently in active development and is being run and tested locally. All services default tolocalhostwith environment-specific configurations. Production deployment documentation and guides (Docker, cloud platforms, remote hosts) will be added in upcoming releases. For now, follow the local development setup below.
This framework enables:
- Multi-agent systems: Deploy multiple AI agents that communicate autonomously
- Real-time messaging: Bi-directional gRPC streaming for low-latency message exchange
- AI-powered agents: Built-in support for LLM integration (Groq API)
- Agent orchestration: Coordinator agent that routes tasks between specialist agents
- Web dashboard: Next.js UI for monitoring agents and sending messages
- Persistent storage: PostgreSQL backend for message history and state
- JWT authentication: Secure agent-to-agent and client-to-server communication
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Agent Dashboard (Web UI) β
β Next.js + React + TypeScript β
β - Chat interface β
β - Agent monitoring β
β - Real-time message updates (SSE) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β REST API (axios)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI REST Server β
β - JWT token generation & verification β
β - Message routing & persistence β
β - Agent registry queries β
β - WebSocket/SSE endpoints β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β gRPC Server (Port 50051) β
β - AgentComm (bi-directional streaming) β
β - AgentRegistry (agent registration) β
β - Database polling for message routing β
βββββββββββββββββββββββββββββββββββββββββββ
β² β β²
β β β
β gRPC β Postgres β gRPC
β Streaming β β
β βΌ β
βββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Coordinator Message Agent Config/
β Agent Database Metadata
β β
β ββββββββββββββββββββββββ β
β β - Orchest tasks β β
β β - Route to agents β β
β β - Synthesize results β β
β ββββββββββββββββββββββββ β
βββββββββββββββ β
β² βΌ
β ββββββββββββββββββ
βββββββββββββββββββΊβ Research Agent β
β β Research Agent β
βββββββββββββββββββΊβ Code Agent β
β β etc... β
βββββββββββββββββββββββββββββββββββββ
βββ server/ # Python gRPC backend
β βββ main.py # gRPC server implementation
β βββ api.py # FastAPI REST API layer
β βββ auth.py # JWT token generation & verification
β βββ agent_comm_pb2.py # Generated protobuf Python files
β βββ agent_comm_pb2_grpc.py # Generated gRPC service stubs
β
βββ sdk/ # Python Agent SDK
β βββ agent.py # Base AgentClient class
β βββ intelligent_agent.py # AI-powered agent with LLM support
β βββ coordinator_agent.py # Task orchestration agent
β βββ code_agent.py # Code-focused specialist agent
β βββ research_agent.py # Research/analysis specialist agent
β βββ demo_agent.py # Demo example agent
β βββ smart_coordinator.py # Advanced coordinator
β βββ agent_comm_pb2*.py # Generated protobuf files
β
βββ agent-dashboard/ # Next.js web UI
β βββ app/
β β βββ page.tsx # Home page
β β βββ login/ # Authentication
β β βββ chat/ # Chat interface
β β βββ layout.tsx # Root layout
β β βββ components/
β β β βββ ChatInterface.tsx # Agent chat UI
β β β βββ SendMessageForm.tsx # Message composer
β β β βββ ClientLayout.tsx # Client-side layout
β β β βββ ThemeToggle.tsx # Dark mode toggle
β β βββ contexts/
β β β βββ ThemeContext.tsx # Theme provider
β β βββ globals.css
β βββ services/
β β βββ api.ts # API client (axios)
β β βββ index.ts
β βββ hooks/
β β βββ useSSE.ts # Server-Sent Events hook
β βββ package.json
β βββ tsconfig.json
β βββ next.config.ts
β βββ tailwind.config.js
β
βββ proto/
β βββ agent_comm.proto # gRPC service & message definitions
β
βββ requirements.txt # Python dependencies
- DIRECT: Point-to-point messages between agents
- BROADCAST: One agent sends to all others
- EVENT: Event notifications
- REQUEST: Inter-agent request (for coordinator pattern)
- RESPONSE: Reply to a request
- HEARTBEAT: Keep-alive signal
-
Specialist Agents (code-agent, research-agent)
- Focused expertise in a domain
- Respond to direct requests
- Can be chained by coordinator
-
Coordinator Agent
- Receives complex user requests
- Analyzes which specialist(s) to route to
- Synthesizes results into final response
- Manages inter-agent communication
-
Basic Agents
- Simple message send/receive
- No AI/LLM integration
- Good for testing and light tasks
- Python 3.8+
- Node.js 18+ (for dashboard)
- PostgreSQL 12+
- Groq API key (for AI agents): https://console.groq.com
git clone https://github.com/PG1204/AI-Agent-Communication-Framework.git
cd "AI Agent Communication Framework"
# Setup Python
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt
# Setup Node.js
cd agent-dashboard
npm install
cd ..# Create PostgreSQL database
createdb agent_comm_db
# Create schema (connect to database)
psql -d agent_comm_db -c "
CREATE TABLE IF NOT EXISTS agent_messages (
message_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
sender_id TEXT NOT NULL,
recipient_id TEXT,
message_type INTEGER NOT NULL,
payload BYTEA,
timestamp TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
correlation_id TEXT
);
CREATE INDEX idx_recipient_timestamp ON agent_messages(recipient_id, timestamp);
CREATE INDEX idx_sender_timestamp ON agent_messages(sender_id, timestamp);
"Create a .env file in the project root or export environment variables:
Note: Currently configured for local development (localhost). Production deployment configurations will be documented soon.
# Database
export AGENT_DB_USER="your_db_user"
export AGENT_DB_PASSWORD="your_db_password"
export AGENT_DB_HOST="localhost"
export AGENT_DB_PORT="5432"
export AGENT_DB_NAME="agent_comm_db"
# JWT
export JWT_SECRET="your-super-secret-key-change-this-in-production"
export JWT_ALGORITHM="HS256"
export JWT_EXPIRY_MINUTES="60"
# AI Integration
export GROQ_API_KEY="your-groq-api-key"
# API URLs
export NEXT_PUBLIC_API_URL="http://localhost:8000"
export GRPC_HOST="localhost:50051"Terminal 1 - gRPC Server:
python server/main.py
# Expected: "π Starting gRPC server on [::]:50051..."
# Expected: "β
Server started and ready!"Terminal 2 - REST API (FastAPI):
uvicorn server.api:app --reload --port 8000
# Expected: "Uvicorn running on http://127.0.0.1:8000"Terminal 3 - Dashboard:
cd agent-dashboard
npm run dev
# Expected: "β² Next.js 15.5.4"
# Open: http://localhost:3000Terminal 4+ - Launch Agents:
# Coordinator Agent (orchestrates tasks)
python sdk/coordinator_agent.py
# Research Agent (in another terminal)
python sdk/research_agent.py
# Code Agent (in another terminal)
python sdk/code_agent.pyPOST /token
{
"agent_id": "my-agent"
}
Response:
{
"access_token": "eyJ0...",
"token_type": "bearer"
}POST /messages/send
Authorization: Bearer <token>
{
"sender_id": "agent-1",
"recipient_id": "agent-2",
"message_type": 0,
"payload": "Hello Agent 2!",
"correlation_id": "optional-id"
}GET /messages?agent_id=agent-1&limit=20&offset=0
Authorization: Bearer <token>GET /agents?agent_id=agent-1
Authorization: Bearer <token>GET /conversations/{other_agent_id}?agent_id=agent-1&limit=50
Authorization: Bearer <token>See proto/agent_comm.proto for detailed service definitions:
rpc RegisterAgent(RegisterAgentRequest) returns (RegisterAgentResponse);Registers a new agent and returns a JWT token.
rpc StreamMessages(stream AgentMessage) returns (stream AgentMessage);Bi-directional streaming for real-time message exchange.
import asyncio
from sdk.agent import AgentClient
async def main():
agent = AgentClient("my-simple-agent")
# Register with server
await agent.register_agent()
# Send a direct message
await agent.send_direct_message("recipient-agent-id", "Hello!")
# Send broadcast
await agent.send_broadcast_message("Hello everyone!")
# Run agent (listen for incoming messages)
await agent.run()
if __name__ == "__main__":
asyncio.run(main())import asyncio
import os
from sdk.intelligent_agent import IntelligentAgent
SYSTEM_PROMPT = """You are a helpful assistant specialized in [your domain].
Focus on [specific capabilities].
Keep responses concise and actionable."""
async def main():
agent = IntelligentAgent(
agent_id="my-ai-agent",
system_prompt=SYSTEM_PROMPT,
groq_api_key=os.getenv("GROQ_API_KEY")
)
await agent.connect()
if __name__ == "__main__":
asyncio.run(main())import asyncio
import os
from sdk.intelligent_agent import IntelligentAgent
COORDINATOR_PROMPT = """You are a Coordinator Agent.
When you receive a request:
1. Analyze what needs to be done
2. Decide which specialist agent(s) to send it to
3. Send request using format: "REQUEST TO [agent-name]: [specific task]"
4. Wait for responses and synthesize them"""
async def main():
agent = IntelligentAgent(
agent_id="coordinator-agent",
system_prompt=COORDINATOR_PROMPT,
groq_api_key=os.getenv("GROQ_API_KEY")
)
await agent.connect()
if __name__ == "__main__":
asyncio.run(main())- Agent Registration β gRPC
RegisterAgent()β Returns JWT token - Agent Connection β Includes token in gRPC metadata:
Authorization: Bearer <token> - Message Sending β REST API validates token via
verify_jwt() - Dashboard Login β Same JWT flow for web users
- Move
JWT_SECRETto environment variables (never hardcode) - Use strong, randomly generated JWT secrets (32+ characters)
- Rotate tokens regularly (currently 60-minute expiry)
- Use HTTPS in production
- Add database password from environment (not hardcoded)
- Implement agent credential verification before registration
- Add rate limiting to REST API endpoints
- Use connection pooling with asyncpg (already implemented)
If you modify proto/agent_comm.proto:
python -m grpc_tools.protoc \
-I./proto \
--python_out=./server \
--grpc_python_out=./server \
./proto/agent_comm.proto
# Copy to SDK for agents
cp server/agent_comm_pb2*.py sdk/# Test agent registration
python sdk/test_auth_client.py
# Test messaging (after server is running)
python sdk/agent.py test-agent-1 # Terminal 1
python sdk/agent.py test-agent-2 # Terminal 2- gRPC Server Logs: Watch
server/main.pyoutput for connection/message flow - API Server Logs: Check
uvicornconsole for HTTP requests - Agent Logs: Each agent prints its operations (connection, send, receive)
- Dashboard: Check browser console (F12) for frontend errors
1. Launch code-agent and research-agent
2. Open http://localhost:3000
3. Log in with agent ID
4. Select other agent from list
5. Send message β both agents receive and respond
User Request: "How do I build a REST API in Python and compare it with gRPC?"
Coordinator Flow:
1. Receives request from user/dashboard
2. Routes to code-agent: "Write example REST API in Python"
3. Routes to research-agent: "Compare REST vs gRPC"
4. Waits for both responses
5. Synthesizes final answer
6. Sends back to user via dashboard
1. Multiple specialist agents running
2. Dashboard shows live agent status
3. Message history visible
4. Admin can send broadcast messages to all agents
5. View message flow and response times
-
Database credentials in source code (server/main.py, server/api.py)
- Need to migrate to environment variables
-
No persistent agent state beyond message history
- Consider adding agent metadata table for status, capabilities
-
No rate limiting on REST API
- Consider adding FastAPI slowapi
-
Groq API rate limits for AI agents
- Currently has retry logic with exponential backoff
-
No agent discovery service
- Agents must be manually registered or hardcoded in coordinator
-
WebSocket/SSE not fully implemented
- Dashboard uses polling instead of true push updates
-
No message encryption (TLS/SSL)
- Add in production environments
fastapi- REST API frameworkuvicorn- ASGI servergrpcio- gRPC runtimeprotobuf- Protocol buffersasyncpg- Async PostgreSQL driverpydantic- Data validationpython-jose- JWT implementationgroq- Groq API clientpython-dotenv- Environment variable management
next15.5.4 - React frameworkreact19.1.0 - UI libraryaxios- HTTP clienttailwindcss- Stylinglucide-react- Icons
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -am "Add your feature" - Push to branch:
git push origin feature/your-feature - Create a Pull Request
This project is open source. Specify your license here.
- Ensure gRPC server is running:
python server/main.py - Check if port is already in use:
lsof -i :50051
- Ensure PostgreSQL is running and database schema is created
- Verify database connection settings in environment variables
- Regenerate token via
/tokenendpoint - Check JWT_SECRET matches between server/main.py and server/auth.py
- Verify token expiration (60 minutes default)
- Check agent is registered (should print "Registered with ID")
- Verify recipient_id is correct
- Check database for messages (they may be persisted but not routed)
- Check gRPC server logs for routing errors
- Verify REST API running on http://localhost:8000
- Check browser CORS settings
- Verify
NEXT_PUBLIC_API_URLenvironment variable
- Wait a few minutes before retrying
- Reduce max_tokens in IntelligentAgent (currently 500)
- Consider caching responses for repeated queries
- gRPC Documentation
- Protocol Buffers Guide
- FastAPI Documentation
- Next.js Documentation
- Groq API Documentation
- PostgreSQL Async Python
Created: December 2024
Repository: https://github.com/PG1204/AI-Agent-Communication-Framework
Branch: new-improvements
For issues and feature requests, please use the GitHub Issues page.