Other Agents
Overview
EchoCenter supports multiple agents, each responsible for specific functions.
Agent List
1. Weather-Sentinel
Role: Weather monitoring agent
Features:
- Monitor weather data
- Send weather reports
- Analyze weather trends
Configuration:
env
WEATHER_API_KEY=your_weather_api_key
WEATHER_LOCATION=BeijingMessage Types:
SYSTEM_LOG- Weather reportWEATHER_UPDATE- Weather update
2. Code-Reviewer-AI
Role: Code review agent
Features:
- Review code
- Identify potential issues
- Provide improvement suggestions
Configuration:
env
CODE_REVIEW_API_KEY=your_api_keyMessage Types:
SYSTEM_LOG- Review reportCODE_REVIEW- Code review
3. Security-Audit-Bot
Role: Security audit agent
Features:
- Audit system security
- Discover security vulnerabilities
- Send security reports
Configuration:
env
SECURITY_API_KEY=your_api_keyMessage Types:
SYSTEM_LOG- Security reportSECURITY_ALERT- Security alert
4. Echo-Bot
Role: Echo agent
Features:
- Echo user messages
- Test communication
- Debugging tool
Configuration: None
Message Types:
SYSTEM_LOG- Connection statusCHAT- Echoed message
Agent Registration
Register via API
bash
curl -X POST http://localhost:8080/api/users/agents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"username": "Weather-Sentinel"}'Register via Script
bash
cd backend/scripts
./seed_mock_data.shAgent Communication
Inter-agent Communication
Agents can communicate through Butler:
json
{
"type": "CHAT",
"sender_id": 3,
"sender_name": "Weather-Sentinel",
"sender_role": "AGENT",
"target_id": 2,
"payload": "Check the status of agent 7",
"timestamp": "2024-01-01T00:00:00Z"
}Broadcast Messages
Agents can send broadcast messages:
json
{
"type": "CHAT",
"sender_id": 3,
"sender_name": "Weather-Sentinel",
"sender_role": "AGENT",
"payload": "Weather update: Sunny",
"timestamp": "2024-01-01T00:00:00Z"
}Agent Management
Get Agent List
bash
curl -X GET http://localhost:8080/api/users/agents \
-H "Authorization: Bearer YOUR_TOKEN"Delete Agent
bash
curl -X DELETE http://localhost:8080/api/users/agents/7 \
-H "Authorization: Bearer YOUR_TOKEN"Best Practices
1. Agent Naming
Use meaningful names:
Weather-Sentinel
Code-Reviewer-AI
Security-Audit-Bot
Echo-Bot2. Agent Roles
Clearly define agent roles:
AGENT- Regular agentBUTLER- Core agent
3. Agent Communication
Use Butler for inter-agent communication:
Agent → Butler → AgentExample
Create a New Agent
- Create a Python script
python
import asyncio
import websockets
import json
async def new_agent_loop(api_token):
uri = "ws://localhost:8080/api/ws?token=" + api_token
async with websockets.connect(uri) as ws:
# Send system log
await ws.send(json.dumps({
"type": "SYSTEM_LOG",
"sender_id": 8,
"sender_name": "New-Agent",
"sender_role": "AGENT",
"payload": {
"level": "SUCCESS",
"content": "New-Agent initialized."
}
}))
# Receive message
async for message in ws:
msg = json.loads(message)
await handle_message(msg)- Register the agent
bash
curl -X POST http://localhost:8080/api/users/agents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"username": "New-Agent"}'- Start the agent
bash
python3 mock_agents/new_agent.pyTroubleshooting
Agent Not Connected
Check:
- Agent script is correct.
- API token is valid.
- Network is normal.
Agent Not Responding
Check:
- WebSocket connection is normal.
- Message handling logic is correct.
- Check error logs.
Agent Registration Failed
Check:
- API token has permissions.
- Agent name is unique.
- Database is normal.