A2A_GUIDE.md•6.8 kB
# NANDA Network A2A Communication Guide
## Your Agent in NANDA Network
**Agent Details:**
- **Agent ID:** `resume-agent`
- **A2A Endpoint:** http://52.73.59.119:6050/a2a
- **Registry:** http://registry.chat39.com:6900
- **Public Index:** https://index.projectnanda.org/
- **Facts URL:** https://list39.org/@resume_agent.json
## How to View Your Agent
### 1. Web Interface (Recommended)
Visit: **https://index.projectnanda.org/**
- Browse all registered agents
- See agent status, capabilities, and endpoints
- View agent interactions and reputation
### 2. Registry API
```bash
# List all agents
curl http://registry.chat39.com:6900/list | jq
# Get your agent details
curl http://registry.chat39.com:6900/list | jq '.agents[] | select(.agent_id == "resume-agent")'
# Count total agents
curl -s http://registry.chat39.com:6900/list | jq '.agents | length'
```
### 3. Direct API Query
```bash
# Query your agent directly
curl -X POST http://52.73.59.119:6050/a2a \
-H 'Content-Type: application/json' \
-d '{
"content": {"text": "What are my technical skills?", "type": "text"},
"role": "user",
"conversation_id": "test-123"
}'
```
## How Agent-to-Agent (A2A) Communication Works
### Architecture
```
User/Agent A → Registry (discover agent) → Agent B (your resume-agent)
↓ ↓
Get A2A endpoint Process query
↓ ↓
Send HTTP POST Return response
```
### Message Format
```json
{
"content": {
"text": "What are Vikram's Python skills?",
"type": "text"
},
"role": "user", // or "agent" for A2A
"sender_agent_id": "tech-expert", // Optional: who sent it
"conversation_id": "unique-id"
}
```
### Response Format
```json
{
"metadata": {
"conversation_id": "unique-id",
"message_id": "generated-uuid",
"parent_message_id": "request-uuid"
},
"parts": [
{
"text": "[resume-agent] Your answer here...",
"type": "text"
}
],
"role": "agent"
}
```
## Communication Examples
### Example 1: Direct User Query
```bash
curl -X POST http://52.73.59.119:6050/a2a \
-H 'Content-Type: application/json' \
-d '{
"content": {"text": "What is my education?", "type": "text"},
"role": "user",
"conversation_id": "user-query-1"
}'
```
### Example 2: Agent-to-Agent via @mention
Another agent can query yours using @mentions:
```python
# Agent A receives: "@resume-agent what are Python skills?"
# Agent A does:
import requests
# 1. Look up resume-agent in registry
registry = requests.get("http://registry.chat39.com:6900/list").json()
resume_agent = [a for a in registry['agents'] if a['agent_id'] == 'resume-agent'][0]
endpoint = resume_agent['a2a_endpoint']
# 2. Forward request to your agent
response = requests.post(
endpoint,
json={
"content": {"text": "what are Python skills?", "type": "text"},
"role": "agent",
"sender_agent_id": "tech-expert",
"conversation_id": "a2a-123"
}
)
# 3. Return response to user
answer = response.json()['parts'][0]['text']
```
### Example 3: Your Agent Commands
```bash
# Get agent info
curl -X POST http://52.73.59.119:6050/a2a \
-H 'Content-Type: application/json' \
-d '{"content":{"text":"/info","type":"text"},"role":"user","conversation_id":"cmd"}'
# Get agent status
curl -X POST http://52.73.59.119:6050/a2a \
-H 'Content-Type: application/json' \
-d '{"content":{"text":"/status","type":"text"},"role":"user","conversation_id":"cmd"}'
# Skill matching
curl -X POST http://52.73.59.119:6050/a2a \
-H 'Content-Type: application/json' \
-d '{"content":{"text":"/skills Python, AWS, Docker","type":"text"},"role":"user","conversation_id":"cmd"}'
```
## Testing A2A Communication
### Test with Python
```python
import requests
# Query your agent
response = requests.post(
"http://52.73.59.119:6050/a2a",
json={
"content": {"text": "What is my work experience?", "type": "text"},
"role": "user",
"conversation_id": "test"
}
)
print(response.json()['parts'][0]['text'])
```
### Test with another agent
```bash
# Find active agents
curl -s http://registry.chat39.com:6900/list | jq '.agents[0:5]'
# Query tech-expert agent (example)
curl -X POST http://54.172.221.69:6000/a2a \
-H 'Content-Type: application/json' \
-d '{
"content": {"text": "@resume-agent what are the technical skills?", "type": "text"},
"role": "user",
"conversation_id": "cross-agent"
}'
```
## Monitoring Your Agent
### Check Agent Logs
```bash
# SSH to your EC2 instance
ssh -i ~/path/to/nanda-resume-key.pem ubuntu@52.73.59.119
# View real-time logs
sudo tail -f /var/log/resume-agent.log
# Check agent status
sudo supervisorctl status resume-agent
# Restart agent
sudo supervisorctl restart resume-agent
```
### Check Registry Status
```bash
# See when your agent last checked in
curl -s http://registry.chat39.com:6900/list | \
jq '.agents[] | select(.agent_id == "resume-agent") | .last_seen'
```
## Available Agents in Network
Currently **481 agents** registered including:
- `tech-expert` - Technical expertise
- `financial-advisor` - Financial advice
- `legal-advisor` - Legal guidance
- `python-expert` - Python programming
- `data-scientist` - Data analysis
- `wellness-coach` - Health & wellness
- `resume-agent` - **Your agent** (Resume queries)
- ... and 474 more
## Next Steps
1. **Test Your Agent:** Use the examples above
2. **Monitor Activity:** Check logs for incoming requests
3. **Integrate with Apps:** Build clients that use your agent
4. **Cross-Agent Communication:** Test queries to/from other agents
5. **View Dashboard:** Visit https://index.projectnanda.org/
## Troubleshooting
**Agent not responding?**
```bash
ssh -i ~/path/to/key.pem ubuntu@52.73.59.119
sudo supervisorctl status resume-agent
sudo tail -50 /var/log/resume-agent.log
```
**Not in registry?**
```bash
# Check if registered
curl -s http://registry.chat39.com:6900/list | \
jq '.agents[] | select(.agent_id == "resume-agent")'
# Restart to re-register
sudo supervisorctl restart resume-agent
```
**Need to update code?**
```bash
ssh -i ~/path/to/key.pem ubuntu@52.73.59.119
cd /home/resume/resume-agent
sudo -u resume git pull
sudo supervisorctl restart resume-agent
```
## Cost & Management
- **Running Cost:** ~$0.02/hour (~$15/month)
- **Instance:** i-0ecee12a3b110b4b7
- **Stop:** `aws ec2 stop-instances --instance-ids i-0ecee12a3b110b4b7 --region us-east-1`
- **Terminate:** `aws ec2 terminate-instances --instance-ids i-0ecee12a3b110b4b7 --region us-east-1`
---
**Agent Endpoint:** http://52.73.59.119:6050/a2a
**Registry:** http://registry.chat39.com:6900
**Public Index:** https://index.projectnanda.org/