Agents¶
Agents are the core building blocks of AG2Trust. Each agent is an AI-powered entity that can process messages, use tools, and collaborate with other agents.
What is an Agent?¶
An agent in AG2Trust is:
- A containerized instance running an LLM-powered assistant
- Configured with a system prompt defining its behavior
- Equipped with tools (capabilities) for specific tasks
- Isolated in its own Docker container for security
Agent Architecture¶
┌─────────────────────────────────────────────────┐
│ Agent Container │
│ ┌─────────────────────────────────────────┐ │
│ │ AG2 Framework (AutoGen) │ │
│ │ ┌─────────────┐ ┌─────────────────┐ │ │
│ │ │ LLM Adapter │ │ Tool Executor │ │ │
│ │ │ (OpenAI/ │ │ (13 built-in │ │ │
│ │ │ Anthropic) │ │ tools) │ │ │
│ │ └─────────────┘ └─────────────────┘ │ │
│ └─────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────┐ │
│ │ Redis Messaging │ │
│ │ IN: agent.{id}.in │ │
│ │ OUT: agent.{id}.out │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
Agent Types¶
AG2Trust distinguishes between two agent management patterns:
Standalone Agents (Pets)¶
- Individually managed via the Agents page
- Custom names chosen by users
- Ideal for unique, specialized agents
- Manual scaling
Team Deployment Agents (Cattle)¶
- Auto-scaled via Team Deployments
- System-generated names:
{team-slug}-{type-slug}-N - Managed as a group/pool
- Automatic reconciliation to desired replica count
Creating Agents¶
Required Configuration¶
| Field | Description | Example |
|---|---|---|
| Name | Unique identifier | "support-bot-1" |
| Agent Type | Template to use | "customer-support" |
| Provider | LLM provider | "openai-production" |
Optional Configuration¶
| Field | Description | Default |
|---|---|---|
| Temperature | Randomness (0-1) | 0.7 |
| Max Tokens | Response limit | Model default |
| Tools | Enabled capabilities | From agent type |
Agent Lifecycle¶
States¶
stateDiagram-v2
[*] --> created
created --> running: Start
running --> idle: 30s inactivity
idle --> running: Message received
running --> stopped: Stop
stopped --> running: Start
running --> error: Failure
error --> running: Restart
stopped --> [*]: Delete | State | Description | Billing |
|---|---|---|
created | Configured, not started | No |
running | Active, processing | Yes |
idle | Running, no activity | Yes |
stopped | Manually stopped | No |
error | Failed, needs attention | No |
Health Monitoring¶
AG2Trust monitors agent health through:
- Heartbeat: Agents publish heartbeat every 30 seconds (90s TTL)
- Container Reconciliation: Backend checks Docker every 60 seconds
Agent Communication¶
Receiving Messages¶
Agents receive messages via Redis pub/sub:
Sending Responses¶
Agents publish responses to:
Message Format¶
{
"version": "1.0",
"timestamp": "2025-01-15T10:30:00Z",
"trace_id": "abc123",
"sender": "customer-api",
"recipient": "agent-1",
"payload_type": "chat",
"payload": {
"message": "Hello, I need help with my order"
}
}
Agent Tools¶
Agents can use built-in tools based on their assigned capabilities:
File Operations¶
read_file- Read file contentswrite_file- Write/create fileslist_directory- List directory contentsdelete_file- Remove filesfile_exists- Check file existence
Git Operations¶
git_status- Check repository statusgit_diff- View changesgit_commit- Commit changesgit_push- Push to remotegit_pull- Pull from remote- Plus 7 more git tools
Web Operations¶
http_get- Make GET requestshttp_post- Make POST requests
Search¶
web_search- Search the internet
Collaboration¶
discover_agent- Find other agents in teamsend_agent_message- Message another agent
Security¶
Container Isolation¶
Each agent runs in an isolated Docker container with:
- Read-only
/appdirectory - Write access only to
/workspace - Non-root user execution
- Resource limits (memory, CPU)
Network Isolation¶
┌─────────────────────────────────────┐
│ ag2trust-internal │
│ (Redis, Postgres - no internet) │
├─────────────────────────────────────┤
│ ag2trust-public │
│ (LLM API access only) │
└─────────────────────────────────────┘
Rate Limiting¶
| Operation | Limit |
|---|---|
| Tool calls | 5/minute |
| HTTP requests | 3/minute |
| Web search | 3/minute |
| Git push | 10/hour |
Best Practices¶
1. Use Descriptive Names¶
2. Keep System Prompts Focused¶
# Good: Specific role
You are a Python code reviewer. Review code for:
- Security vulnerabilities
- Performance issues
- Best practice violations
# Avoid: Vague instructions
You are an AI assistant that helps with things.
3. Configure Appropriate Tools¶
Only enable tools the agent needs:
| Use Case | Recommended Capabilities |
|---|---|
| Code review | code_review |
| Research | research |
| DevOps | git_full, file_operations |
4. Monitor Resource Usage¶
Track in the Dashboard: - Token consumption - Response times - Error rates
API Operations¶
Start Agent¶
Stop Agent¶
Send Message¶
See API Reference for complete documentation.