Agent Registry A2A Protocol Integration
Date: 2025-04-26 Participants: AI Assistant, Rakesh Gangwar
Context
Building on our initial Agent Registry implementation, we've enhanced the agent model to support the A2A (Agent-to-Agent) protocol and improved the overall agent schema to better handle different agent types and capabilities.
Discussion
A2A Protocol Support
- A2A Protocol Requirements:
- Standard protocol for interoperability between agents from different systems
- Requires specific metadata and capabilities description
- Enables discovery and communication between agents
-
Supports various interaction modes (text, files, data)
-
A2A Agent Card Format:
- Name, description, version (already supported)
- URL for agent endpoint (new)
- Provider information (new)
- Capabilities object with streaming, push notifications, history support (new)
- Authentication details (new)
- Input/output modes (similar to our modalities)
-
Skills array with detailed abilities (new)
-
Schema Comparison:
- Identified differences between our model and A2A requirements
- Found inconsistencies between backend model and frontend mock data
- Consolidated all requirements into a unified schema
Implementation Details
- Enhanced Agent Model:
- Added type classification with execution_type field
- Added status field (active, inactive, deprecated)
- Added last_used timestamp for usage tracking
- Added capabilities array to complement modalities
-
Added A2A protocol support fields:
- URL, provider details, authentication details
- Capability flags for streaming, push, history
-
Agent Skills Model:
- Created new table for structured skill representation
- Supports detailed descriptions of agent capabilities
- Includes examples and I/O modes per skill
-
Maps to A2A protocol skills concept
-
Schema Updates:
# New fields for Agent model execution_type = Column(String(100)) # docker, api, a2a, framework, edge status = Column(String(50), default="active") last_used = Column(DateTime) capabilities = Column(JSON) url = Column(String(255)) provider_name = Column(String(100)) provider_url = Column(String(255)) authentication_type = Column(String(50)) authentication_config = Column(JSON) capabilities_streaming = Column(Boolean, default=False) capabilities_push = Column(Boolean, default=False) capabilities_history = Column(Boolean, default=False) -
Agent Skills Schema:
Challenges & Solutions
- Schema Differences:
- Found inconsistency between backend and frontend models
- Type field had different values (e.g., "text" vs. "llm")
-
Solution: Added type mapping for frontend display
-
A2A Integration:
- Added well-known endpoint pattern for A2A Agent Card
- Created format conversion between our schema and A2A format
-
Maintained backward compatibility with existing code
-
Field Normalization:
- Organized fields into logical groups
- Ensured consistent naming conventions
- Added proper documentation and comments
Implementation Progress
A2A Protocol Endpoints
- Well-Known Endpoint:
- Implemented
GET /agents/{agent_id}/.well-known/agent.jsonendpoint - Dynamically generates A2A Agent Card from our internal model
- Handles conversion between our data model and A2A protocol format
-
Exposes agent skills and capabilities in the standard format
-
A2A Task Management Endpoints:
-
Implemented basic A2A protocol endpoints for task interaction:
POST /a2a/{agent_id}/tasks/send- Send message to initiate/continue a taskPOST /a2a/{agent_id}/tasks/sendSubscribe- Send message with SSE streamingPOST /a2a/{agent_id}/tasks/get- Get current task statePOST /a2a/{agent_id}/tasks/cancel- Cancel a running taskPOST /a2a/{agent_id}/tasks/pushNotification/set- Configure push notificationsPOST /a2a/{agent_id}/tasks/pushNotification/get- Get push notification config
-
Streaming Support:
- Added Server-Sent Events (SSE) implementation for real-time updates
- Supports incremental responses from agents
-
Provides structured message format for streaming interactions
-
Authentication Integration:
- Added
get_current_user_idfunction to extract UUID from user token - Ensured authenticated access to A2A endpoints
- Maintains security while enabling agent interoperability
Technical Details
-
Message Format:
class Message(BaseModel): role: str = Field(..., description="Message role (user, agent)") parts: list[MessagePart] = Field(..., description="Message parts") metadata: Optional[Dict[str, Any]] = Field(None, description="Message metadata") class MessagePart(BaseModel): type: str = Field(..., description="Part type (text, file, data)") text: Optional[str] = Field(None, description="Text content") file: Optional[Dict[str, Any]] = Field(None, description="File content") data: Optional[Dict[str, Any]] = Field(None, description="Structured data") -
SSE Implementation:
@router.post("/a2a/{agent_id}/tasks/sendSubscribe") async def send_task_subscribe(agent_id: UUID, params: TaskSendParams): # This is a simplified StreamingResponse example async def event_generator(): yield format_sse_event(json.dumps({ "id": "task-123", "status": { "state": "working", "timestamp": "..." } })) # Additional events... return StreamingResponse(event_generator(), media_type="text/event-stream") -
A2A Card Generation:
agent_card = { "name": agent.name, "description": agent.description, "url": agent.url or agent_url, "provider": { "name": agent.provider_name, "url": agent.provider_url }, "capabilities": { "streaming": agent.capabilities_streaming, "pushNotifications": agent.capabilities_push, "stateTransitionHistory": agent.capabilities_history }, "skills": [ /* skill mappings */ ] }
Decision
- Unified Agent Schema:
- Consolidated backend model, frontend expectations, and A2A requirements
- Created complete schema documentation
-
Added clear comments for all fields
-
Frontend Integration:
- Planned API service for agent operations
- Created type mapping helpers for frontend display
-
Ensured consistent data format across all components
-
A2A Protocol Support:
- Implemented fields needed for A2A protocol compatibility
- Added support for skills representation
- Created A2A Card endpoint format
- Implemented core A2A protocol endpoints
Next Steps
- Remaining API Implementation:
- Add endpoints for agent skills CRUD operations
- Enable direct skill management through API
-
Implement full task persistence and management
-
Frontend Updates:
- Create agentApi.ts service
- Update agent-store.ts to use backend API
-
Add UI for editing agent skills and A2A fields
-
Testing:
- Add tests for new schema validation
- Validate A2A Card generation
- Test type mapping and conversions
-
Verify authenticated endpoint access
-
Documentation:
- Update API documentation with new fields
- Document A2A protocol integration
- Create guide for agent skills management
- Add usage examples for A2A protocol endpoints