This proof of concept implements a basic version of the Agent Communication & Discovery Protocol, allowing AI agents to register, discover, communicate with each other, and share memory. It uses a cybersecurity scenario (see agent capabilities) and so long as you phrase your communication as a question, they will collaborate. This implementation is only provided as an example to visualize the approaches outlined in the document. It's not intended to be comprehensive and does not cover any of the security related options outlined at all.
- DNS Server (BIND9): Provides DNS-based discovery with SRV and TXT records
- Central Registry: Flask-based service for agent registration, discovery, and shared memory
- Agents: Multiple Anthropic Sonnet-powered agents that register, discover each other, and collaborate
You will require a BIND server as a Docker image: BIND 9
-
Clone this repository
-
The PoC uses Anthropic's Sonnet. Set your Anthropic API key in an environment variable:
export ANTHROPIC_API_KEY=your_api_key_here
-
Install dependencies (if not using Docker):
pip install -r requirements.txt
-
Start the services:
docker-compose up -d
View registered agents at: http://localhost:5001
dig @localhost _llm-agent._tcp.agent1.agents.local SRV
dig @localhost _llm-agent._tcp.agent1.agents.local TXT
Agent 1: http://localhost:8001/chat Agent 2: http://localhost:8002/chat Agent 3: http://localhost:8003/chat
Example API call:
curl -X POST http://localhost:8001/chat -H "Content-Type: application/json" -d '{"text": "Hello, can you help me with something?"}'
curl http://localhost:8001/peers
curl http://localhost:8001/metadata
The system includes a shared memory feature allowing agents to store and retrieve information through the central registry.
View all memory entries:
curl http://localhost:8001/memory
Get a specific memory entry:
curl http://localhost:8001/memory/agent_memory_agent1.agents.local
Add or update a memory entry:
curl -X POST http://localhost:8001/memory -H "Content-Type: application/json" -d '{
"key": "shared_notes",
"value": {"topic": "weather", "note": "It will rain tomorrow"},
"owner": "agent1.agents.local"
}'
The registry dashboard provides a UI for viewing and managing shared memory at: http://localhost:5001
Navigate to the "Shared Memory" tab to:
- View all memory entries
- Add new memory entries
- See which agent owns each memory entry
Agents are defined in docker-compose.yml
# Add the new agent with correct context
agent5:
build:
context: .
dockerfile: Dockerfile
ports:
- "8005:8000"
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- AGENT_ID=agent5.agents.local
- AGENT_NAME=Agent Analyzer
- AGENT_DESCRIPTION=AI assistant specializing in security analysis and threat detection
- AGENT_PORT=8000
- AGENT_HOSTNAME=agent5
- REGISTRY_URL=http://registry:5000
- DNS_API_URL=http://bind:8053
- AGENT_CAPABILITIES=security,threat_detection,attack_patterns
networks:
- agent_network
This implementation follows the Agent Communication & Discovery Protocol specification:
- Agents register with both DNS (via SRV/TXT records) and a central registry
- Agents discover each other through the registry and maintain peer lists
- Agents communicate directly with each other via REST APIs
- Agents can collaborate by requesting assistance from peers with relevant capabilities
- Agents can store and retrieve information using the shared memory system
- Heartbeats maintain registry consistency
The shared memory system follows a simple client-server model:
- The registry server manages a central in-memory store
- Agents use the registry client to read from and write to this store
- Memory entries are stored as key-value pairs with metadata (owner, timestamp)
- Agents automatically record chat interactions in memory for future reference
Agents can collaborate to solve problems through:
- Capability-based Discovery: Agents find peers with specific abilities
- Assistance Requests: Agents can ask peers for help on specific questions
- Knowledge Sharing: Agents can reference shared memory for context
- Collective Response: Agents combine peer responses with their own knowledge
When an agent receives a question that might benefit from collaboration:
- It identifies peers with relevant capabilities
- It sends assistance requests to those peers
- It collects responses from peers
- It crafts a comprehensive response that incorporates peer knowledge
- It records the interaction in shared memory
This proof of concept can be extended with:
- Authentication and security measures
- Additional agent capabilities
- Peer-to-peer task delegation
- DNSSEC for DNS security
- HTTPS for transport layer security
- Persistent storage for agent and shared memory
-
Start the System:
docker compose up -d
Check logs to verify all components start correctly:
docker compose logs registry docker compose logs agent1 docker compose logs agent2
-
Registry Discovery Test:
-
Access the registry dashboard to see registered agents:
http://localhost:5001/
-
Query the registry API directly:
curl http://localhost:5001/agents
-
-
DNS Resolution Test:
-
Use
dig
to query agent DNS records:dig @localhost -p 5353 _llm-agent._tcp.agent1.agents.local SRV dig @localhost -p 5353 _llm-agent._tcp.agent1.agents.local TXT
-
-
Ask a Question to an Agent:
curl -X POST http://localhost:8001/chat -H "Content-Type: application/json" -d '{ "text": "Can you analyze the potential security risks of using public WiFi?" }'
In the response, observe if the agent gathered assistance from peers with security expertise.
-
Check Collaboration Logs:
docker compose logs agent1 | grep -E "Question detected|peers for collaboration|Querying peer|peer responses|Received response from peer|Received assistance request from"
-
Record a Chat Interaction:
curl -X POST http://localhost:8001/chat -H "Content-Type: application/json" -d '{"text": "Remember that the project deadline is May 15th"}'
-
Verify the Interaction was Recorded:
curl http://localhost:8001/memory/agent_memory_agent1.agents.local
-
Test Adding Custom Memory:
curl -X POST http://localhost:8001/memory -H "Content-Type: application/json" -d '{ "key": "project_deadlines", "value": {"project_x": "May 15th", "project_y": "June 30th"}, "owner": "user_interface" }'
-
Test Referencing Stored Information:
curl -X POST http://localhost:8001/chat -H "Content-Type: application/json" -d '{"text": "What is the deadline for project X?"}'
The agent should be able to check memory and find the stored deadline information.
-
View Memory in Web UI:
Navigate to http://localhost:5001 and click on the "Shared Memory" tab to view all stored memory entries.
To observe the agent discovery and memory operations in action:
-
Watch the Logs:
# For collaboration docker compose logs -f agent1 | grep -E "peer|discover|gossip" # For memory operations docker compose logs -f agent1 | grep -E "memory|storing|record"
-
Monitor Memory Status:
# Check memory entries periodically curl http://localhost:8001/memory | jq '.memory | keys'