Skip to main content

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

AgentPrimary ResponsibilityA2A IntegrationDownstream Agents
Language AgentLanguage detection and translation to EnglishEntry point for non-English user input→ Summarize Agent
Summarize AgentText summarization and key information extractionProcesses translated text from Language Agent→ Sentiment Agent, Book Agent
Sentiment AgentSentiment analysis and emotional tone evaluationAnalyzes summarized content for sentiment→ Book Agent
Book AgentBook search, recommendations, and catalog queriesMain conversational agent with context from upstream agentsTerminal agent
Rating AgentBook rating analysis and quality classificationProvides rating insights, can delegate to Summarize Agent↔ Summarize Agent (A2A)

Rationale

Why A2A Protocol?

Standardized Agent Communication

  1. Protocol Maturity: A2A is an established open standard designed specifically for agent-to-agent communication
  2. Interoperability: Enables seamless communication between agents built with different frameworks (Semantic Kernel, LangGraph, etc.)
  3. Vendor Independence: Avoid lock-in to proprietary agent communication solutions
  4. Community Support: Backed by Linux Foundation with broad industry adoption and ecosystem support
  5. Future-Proof: Protocol evolution managed by open standards organization

Agent Collaboration Benefits

  1. Context Preservation: Rich context sharing maintains conversation state across agent handoffs
  2. Capability Discovery: Dynamic discovery of agent capabilities enables intelligent routing
  3. Task Delegation: Agents can delegate specialized tasks to other agents (e.g., Rating Agent → Summarize Agent)
  4. Modular Architecture: Each agent focuses on specific expertise while collaborating seamlessly
  5. Scalable Design: Protocol scales with increasing number and complexity of agents

Integration with BookWorm Architecture

  1. Semantic Kernel Integration: A2A Protocol integrates natively with Microsoft Semantic Kernel agent framework
  2. Microservice Compatibility: Agents can be deployed as independent microservices with A2A communication
  3. Event-Driven Architecture: A2A complements existing RabbitMQ messaging for async operations
  4. Authentication Integration: Leverages existing identity and authentication systems
  5. Monitoring Integration: Agent communications are observable through existing telemetry infrastructure

A2A vs Alternative Approaches

Advantages over Direct Function Calls

  1. Location Transparency: Agents can communicate regardless of deployment location (same process, different services)
  2. Protocol Standardization: Standardized message formats vs custom integration code
  3. Error Handling: Built-in error handling and retry mechanisms
  4. Context Management: Rich context preservation across agent boundaries
  5. Scalability: Agents can be scaled independently without breaking communication

Advantages over HTTP/gRPC Direct Integration

  1. Agent-Specific Features: Protocol designed specifically for agent communication patterns
  2. Context Continuity: Persistent conversation context across multiple agent interactions
  3. Capability Advertisement: Built-in service discovery for agent capabilities
  4. Stream Processing: Support for streaming responses and real-time interaction
  5. Agent Lifecycle: Handles agent registration, health monitoring, and graceful shutdown

Complementary with MCP

  1. Different Purposes: A2A for agent-to-agent communication, MCP for agent-to-resource access
  2. Integrated Workflow: Agents use MCP to access data/tools and A2A to collaborate with other agents
  3. Consistent Architecture: Both protocols support the overall agent-driven architecture
  4. 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

RiskImpactProbabilityMitigation Strategy
Agent Communication FailureMediumMediumCircuit breakers, fallback to direct function calls
Protocol Evolution ChangesLowMediumVersion management, backward compatibility
Cross-Service LatencyMediumHighOptimize agent placement, implement caching
Agent Dependency ChainHighLowImplement graceful degradation, agent health monitoring
Context Loss in HandoffsMediumLowComprehensive context serialization, state validation