Skip to content

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=Beijing

Message Types:

  • SYSTEM_LOG - Weather report
  • WEATHER_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_key

Message Types:

  • SYSTEM_LOG - Review report
  • CODE_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_key

Message Types:

  • SYSTEM_LOG - Security report
  • SECURITY_ALERT - Security alert

4. Echo-Bot

Role: Echo agent

Features:

  • Echo user messages
  • Test communication
  • Debugging tool

Configuration: None

Message Types:

  • SYSTEM_LOG - Connection status
  • CHAT - 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.sh

Agent 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-Bot

2. Agent Roles

Clearly define agent roles:

  • AGENT - Regular agent
  • BUTLER - Core agent

3. Agent Communication

Use Butler for inter-agent communication:

Agent → Butler → Agent

Example

Create a New Agent

  1. 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)
  1. 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"}'
  1. Start the agent
bash
python3 mock_agents/new_agent.py

Troubleshooting

Agent Not Connected

Check:

  1. Agent script is correct.
  2. API token is valid.
  3. Network is normal.

Agent Not Responding

Check:

  1. WebSocket connection is normal.
  2. Message handling logic is correct.
  3. Check error logs.

Agent Registration Failed

Check:

  1. API token has permissions.
  2. Agent name is unique.
  3. Database is normal.

Released under the MIT License.