5ca87cd5af
CI / push-validation (pull_request) Successful in 43s
CI / helm (pull_request) Successful in 49s
CI / build (pull_request) Successful in 55s
CI / lint (pull_request) Successful in 1m12s
CI / typecheck (pull_request) Successful in 1m18s
CI / quality (pull_request) Successful in 1m25s
CI / security (pull_request) Successful in 1m28s
CI / unit_tests (pull_request) Successful in 6m23s
CI / docker (pull_request) Successful in 1m47s
CI / integration_tests (pull_request) Successful in 10m51s
CI / coverage (pull_request) Successful in 11m30s
CI / status-check (pull_request) Successful in 4s
- Add v3.6.0 features guide covering advanced context management, enhanced security profiles, improved observability, performance optimizations, and API enhancements - Add v3.7.0 features guide covering TUI redesign, Agent-to-Agent Communication (A2A), enhanced automation execution, advanced skill management, and improved developer experience - Add comprehensive v3.7.0 TUI guide with detailed navigation, management interfaces, keyboard shortcuts, and advanced features - Add v3.7.0 A2A protocol specification covering message format, transport layers, authentication, error handling, and multi-agent orchestration - Add v3.6.0-v3.7.0 release notes with upgrade paths, deprecation timeline, and migration guides - Include practical examples and best practices for all major features - Ensure all documentation is properly formatted with table of contents and cross-references This documentation audit and update provides comprehensive coverage of v3.6.0 and v3.7.0 features with examples, ensuring users can effectively utilize new capabilities.
217 lines
4.4 KiB
Markdown
217 lines
4.4 KiB
Markdown
# CleverAgents v3.7.0 Agent-to-Agent Communication (A2A) Protocol
|
|
|
|
## Overview
|
|
|
|
The Agent-to-Agent Communication (A2A) protocol in CleverAgents v3.7.0 enables sophisticated multi-agent orchestration through a robust, standards-compliant messaging system.
|
|
|
|
## Protocol Specification
|
|
|
|
The A2A protocol is based on JSON-RPC 2.0 with extensions for agent-specific features:
|
|
|
|
- **Standard**: JSON-RPC 2.0 (https://www.jsonrpc.org/specification)
|
|
- **Transport**: HTTP, WebSocket, stdio, gRPC
|
|
- **Encoding**: JSON
|
|
- **Authentication**: Bearer tokens, mTLS
|
|
- **Message Routing**: Agent registry-based routing
|
|
|
|
## Message Format
|
|
|
|
### Request Message
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"method": "automation.execute",
|
|
"params": {
|
|
"automation_id": "auto-123",
|
|
"context": {
|
|
"project_id": "proj-456",
|
|
"user_id": "user-789"
|
|
},
|
|
"timeout": 300
|
|
},
|
|
"id": "msg-abc123"
|
|
}
|
|
```
|
|
|
|
### Response Message
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"result": {
|
|
"status": "success",
|
|
"automation_id": "auto-123",
|
|
"duration": 45.23,
|
|
"output": {
|
|
"records_processed": 1000,
|
|
"errors": 0
|
|
}
|
|
},
|
|
"id": "msg-abc123"
|
|
}
|
|
```
|
|
|
|
### Error Response
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"error": {
|
|
"code": -32603,
|
|
"message": "Internal error",
|
|
"data": {
|
|
"error_type": "AUTOMATION_FAILED",
|
|
"details": "Automation execution failed: timeout after 300s"
|
|
}
|
|
},
|
|
"id": "msg-abc123"
|
|
}
|
|
```
|
|
|
|
## Transport Layers
|
|
|
|
### HTTP Transport
|
|
|
|
HTTP is the default transport for A2A communication.
|
|
|
|
```yaml
|
|
a2a:
|
|
transport: http
|
|
host: 0.0.0.0
|
|
port: 8000
|
|
ssl:
|
|
enabled: true
|
|
cert_file: /path/to/cert.pem
|
|
key_file: /path/to/key.pem
|
|
timeout: 30
|
|
max_connections: 100
|
|
```
|
|
|
|
### WebSocket Transport
|
|
|
|
WebSocket enables bidirectional communication for real-time updates.
|
|
|
|
```yaml
|
|
a2a:
|
|
transport: websocket
|
|
host: 0.0.0.0
|
|
port: 8001
|
|
ssl:
|
|
enabled: true
|
|
cert_file: /path/to/cert.pem
|
|
key_file: /path/to/key.pem
|
|
```
|
|
|
|
### gRPC Transport
|
|
|
|
gRPC transport provides high-performance communication.
|
|
|
|
```yaml
|
|
a2a:
|
|
transport: grpc
|
|
host: 0.0.0.0
|
|
port: 50051
|
|
ssl:
|
|
enabled: true
|
|
cert_file: /path/to/cert.pem
|
|
key_file: /path/to/key.pem
|
|
```
|
|
|
|
## Authentication
|
|
|
|
### Bearer Token Authentication
|
|
|
|
```python
|
|
from cleveragents.a2a import A2AClient
|
|
|
|
client = A2AClient(
|
|
agent_id='local-agent',
|
|
api_key='sk-...',
|
|
base_url='http://localhost:8000'
|
|
)
|
|
|
|
result = await client.call_agent(
|
|
agent_id='remote-agent',
|
|
method='automation.execute',
|
|
params={'automation_id': 'auto-123'}
|
|
)
|
|
```
|
|
|
|
### mTLS Authentication
|
|
|
|
```python
|
|
from cleveragents.a2a import A2AClient
|
|
|
|
client = A2AClient(
|
|
agent_id='local-agent',
|
|
base_url='https://localhost:8000',
|
|
ssl_cert='/path/to/client-cert.pem',
|
|
ssl_key='/path/to/client-key.pem',
|
|
ssl_ca='/path/to/ca-cert.pem'
|
|
)
|
|
```
|
|
|
|
## Error Handling
|
|
|
|
Standard JSON-RPC error codes with custom extensions for A2A:
|
|
|
|
- **-32001**: AGENT_NOT_FOUND
|
|
- **-32002**: AGENT_UNAVAILABLE
|
|
- **-32003**: TIMEOUT
|
|
- **-32004**: AUTHENTICATION_FAILED
|
|
- **-32005**: AUTHORIZATION_FAILED
|
|
- **-32006**: AUTOMATION_FAILED
|
|
|
|
## Multi-Agent Orchestration
|
|
|
|
```python
|
|
from cleveragents.a2a import Orchestrator
|
|
|
|
async def orchestrate_workflow():
|
|
orchestrator = Orchestrator()
|
|
|
|
workflow = orchestrator.create_workflow('data-pipeline')
|
|
|
|
workflow.add_step(
|
|
'extract',
|
|
agent_id='agent-1',
|
|
method='data.extract',
|
|
params={'source': 'database'}
|
|
)
|
|
|
|
workflow.add_step(
|
|
'transform',
|
|
agent_id='agent-2',
|
|
method='data.transform',
|
|
params={'format': 'json'},
|
|
depends_on=['extract']
|
|
)
|
|
|
|
workflow.add_step(
|
|
'load',
|
|
agent_id='agent-3',
|
|
method='data.load',
|
|
params={'destination': 'warehouse'},
|
|
depends_on=['transform']
|
|
)
|
|
|
|
result = await orchestrator.execute_workflow(workflow)
|
|
return result
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
1. **Keep Registry Updated**: Regularly update agent registry with current agents
|
|
2. **Implement Retry Logic**: Use exponential backoff for retries
|
|
3. **Use HTTPS**: Always use HTTPS in production
|
|
4. **Enable mTLS**: Use mutual TLS for agent-to-agent communication
|
|
5. **Connection Pooling**: Reuse connections for multiple requests
|
|
6. **Batch Requests**: Use batch requests for multiple operations
|
|
7. **Audit Logging**: Log all A2A communication for audit purposes
|
|
|
|
---
|
|
|
|
**Last Updated**: April 2024
|
|
**Version**: 3.7.0
|