ADR-021: Agent-to-Agent Communication via A2A Protocol
Status
Accepted - March 2025
Context
BookWorm's intelligent chat system relies on specialized AI agents to provide comprehensive book assistance and customer support. The system requires seamless coordination between multiple agents, each with specific capabilities, to deliver optimal user experiences. The agent communication challenges include:
- Multi-Agent Coordination: Multiple specialized agents (Book, Rating, Summarize, Sentiment, Language) need to collaborate on user requests
- Seamless Agent Handoffs: Smooth transitions between agents without losing conversation context
- Cross-Agent Data Flow: Agents need to share processed information and intermediate results
- Agent Capability Discovery: Dynamic discovery of agent capabilities and availability
- Standardized Communication: Need for standardized protocols for agent-to-agent communication
- Context Preservation: Maintaining conversation context across different agent interactions
- Scalable Architecture: Agent communication must scale with increasing system complexity
- Error Handling: Robust error handling when agents are unavailable or fail
- Real-time Coordination: Near real-time agent collaboration for responsive user interactions
- Agent Orchestration: Intelligent routing of requests to appropriate agents based on capabilities
- Security and Trust: Secure communication channels between agents with proper authentication
- Observability: Comprehensive monitoring and logging of inter-agent communications
The solution must provide a robust, standardized foundation for agent-to-agent communication that enables sophisticated multi-agent workflows.
Decision
Adopt Agent2Agent (A2A) Protocol as the standardized communication protocol for AI agent coordination in the BookWorm intelligent chat system, enabling seamless collaboration between specialized agents.
A2A Protocol Implementation
Agent Communication Framework
- Protocol Compliance: Full compliance with A2A Protocol specification for standardized agent communication
- Agent Discovery: Service discovery mechanisms enabling dynamic agent registration and capability advertisement
- Message Routing: Intelligent routing of requests between agents based on capabilities and context
- Context Management: Persistent conversation context across multi-agent interactions
Agent Orchestration Patterns
- Sequential Processing: Step-by-step processing through agent pipeline (Language → Summarize → Sentiment → Book/Rating)
- Parallel Processing: Concurrent agent execution when appropriate for performance optimization
- Conditional Routing: Dynamic agent routing based on user intent and content analysis
- Fallback Mechanisms: Graceful degradation when specific agents are unavailable
BookWorm Agent Ecosystem
Agent | Primary Responsibility | A2A Integration | Downstream Agents |
---|---|---|---|
Language Agent | Language detection and translation to English | Entry point for non-English user input | → Summarize Agent |
Summarize Agent | Text summarization and key information extraction | Processes translated text from Language Agent | → Sentiment Agent, Book Agent |
Sentiment Agent | Sentiment analysis and emotional tone evaluation | Analyzes summarized content for sentiment | → Book Agent |
Book Agent | Book search, recommendations, and catalog queries | Main conversational agent with context from upstream agents | Terminal agent |
Rating Agent | Book rating analysis and quality classification | Provides rating insights, can delegate to Summarize Agent | ↔ Summarize Agent (A2A) |
Rationale
Why A2A Protocol?
Standardized Agent Communication
- Protocol Maturity: A2A is an established open standard designed specifically for agent-to-agent communication
- Interoperability: Enables seamless communication between agents built with different frameworks (Semantic Kernel, LangGraph, etc.)
- Vendor Independence: Avoid lock-in to proprietary agent communication solutions
- Community Support: Backed by Linux Foundation with broad industry adoption and ecosystem support
- Future-Proof: Protocol evolution managed by open standards organization
Agent Collaboration Benefits
- Context Preservation: Rich context sharing maintains conversation state across agent handoffs
- Capability Discovery: Dynamic discovery of agent capabilities enables intelligent routing
- Task Delegation: Agents can delegate specialized tasks to other agents (e.g., Rating Agent → Summarize Agent)
- Modular Architecture: Each agent focuses on specific expertise while collaborating seamlessly
- Scalable Design: Protocol scales with increasing number and complexity of agents
Integration with BookWorm Architecture
- Semantic Kernel Integration: A2A Protocol integrates natively with Microsoft Semantic Kernel agent framework
- Microservice Compatibility: Agents can be deployed as independent microservices with A2A communication
- Event-Driven Architecture: A2A complements existing RabbitMQ messaging for async operations
- Authentication Integration: Leverages existing identity and authentication systems
- Monitoring Integration: Agent communications are observable through existing telemetry infrastructure
A2A vs Alternative Approaches
Advantages over Direct Function Calls
- Location Transparency: Agents can communicate regardless of deployment location (same process, different services)
- Protocol Standardization: Standardized message formats vs custom integration code
- Error Handling: Built-in error handling and retry mechanisms
- Context Management: Rich context preservation across agent boundaries
- Scalability: Agents can be scaled independently without breaking communication
Advantages over HTTP/gRPC Direct Integration
- Agent-Specific Features: Protocol designed specifically for agent communication patterns
- Context Continuity: Persistent conversation context across multiple agent interactions
- Capability Advertisement: Built-in service discovery for agent capabilities
- Stream Processing: Support for streaming responses and real-time interaction
- Agent Lifecycle: Handles agent registration, health monitoring, and graceful shutdown
Complementary with MCP
- Different Purposes: A2A for agent-to-agent communication, MCP for agent-to-resource access
- Integrated Workflow: Agents use MCP to access data/tools and A2A to collaborate with other agents
- Consistent Architecture: Both protocols support the overall agent-driven architecture
- Standard Compliance: Both are open standards enabling vendor-neutral implementations
Implementation
A2A Integration Points
Chat Service Agent Hosting
- Language Agent: Hosted in Chat service, entry point for non-English input
- Summarize Agent: Hosted in Chat service with A2A endpoint (
/summarize-agent
) - Sentiment Agent: Hosted in Chat service for emotional context analysis
- Book Agent: Primary conversational agent in Chat service
Rating Service Agent Integration
- Rating Agent: Hosted in Rating service with A2A endpoint (
/rating-agent
) - Cross-Service A2A: Rating Agent communicates with Chat service's Summarize Agent via A2A protocol
- Function Integration: Rating Agent uses internal ReviewPlugin and external A2A agents
Agent Capabilities and Skills
Agent Card Specifications
Each agent implements standardized A2A AgentCard with:
- Capabilities: Streaming support, notification preferences
- Skills: Specific tasks and capabilities with examples
- Provider Information: BookWorm organization identifier
- Input/Output Modes: Text-based communication modes
- Version Management: Agent versioning for compatibility
Agent-Specific Configurations
- Language Agent: Temperature 0.1, focused on accurate translation
- Summarize Agent: Temperature 0.2, balanced creativity for summarization
- Sentiment Agent: Temperature 0.2, balanced analysis for sentiment detection
- Book Agent: Function calling enabled, RAG integration for catalog search
- Rating Agent: Temperature 0.1, function calling with contextual selection
Consequences
Positive
- Agent Specialization: Each agent focuses on specific expertise while collaborating seamlessly
- Scalable Architecture: Individual agents can be scaled based on demand and processing requirements
- Modular Development: Agents can be developed, tested, and deployed independently
- Context Continuity: Rich conversation context maintained across multiple agent interactions
- Standard Compliance: Open standard ensures long-term compatibility and vendor independence
- Cross-Service Integration: Agents can collaborate across microservice boundaries (Chat ↔ Rating services)
Negative
- Complexity Increase: Multi-agent coordination adds complexity compared to single-agent systems
- Network Overhead: Inter-agent communication introduces additional network latency
- Debugging Challenges: Multi-agent workflows can be more difficult to debug and troubleshoot
- Protocol Dependency: System becomes dependent on A2A Protocol standard and its evolution
- Agent Dependencies: System reliability depends on availability of multiple agents
Risks and Mitigation
Risk | Impact | Probability | Mitigation Strategy |
---|---|---|---|
Agent Communication Failure | Medium | Medium | Circuit breakers, fallback to direct function calls |
Protocol Evolution Changes | Low | Medium | Version management, backward compatibility |
Cross-Service Latency | Medium | High | Optimize agent placement, implement caching |
Agent Dependency Chain | High | Low | Implement graceful degradation, agent health monitoring |
Context Loss in Handoffs | Medium | Low | Comprehensive context serialization, state validation |