Skip to content

feat: Persistent Task Store and Distributed event bus implementation …#759

Open
hashtekconsulting wants to merge 4 commits intoa2aproject:mainfrom
hashtek-fusion:main
Open

feat: Persistent Task Store and Distributed event bus implementation …#759
hashtekconsulting wants to merge 4 commits intoa2aproject:mainfrom
hashtek-fusion:main

Conversation

@hashtekconsulting
Copy link

feat: Persistent Task Store and Distributed Event Bus/Queue for scaling the A2A server instances in production environment

By default the SDK ships with InMemoryTaskStore and DefaultExecutionEventBusManager, which are perfect for a single-process server. In a production deployment with multiple server instances behind a load balancer you need:

Persistent task state — so any instance can serve a tasks/get request regardless of which instance originally handled the task.
Distributed SSE fan-out — so a client that opens an SSE stream on Instance B receives events published by the executor running on Instance A.
This feature introduced new components to support A2A server scalability in production environment

@hashtekconsulting hashtekconsulting requested a review from a team as a code owner March 4, 2026 02:03
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the A2A server's scalability by introducing robust mechanisms for handling task state and event propagation in multi-instance production environments. It moves beyond in-memory solutions to leverage AWS services like DynamoDB, SNS, and SQS, ensuring data consistency and reliable event delivery across a cluster of servers. The changes allow for seamless operation behind a load balancer, where clients can connect to any instance and still receive all relevant events and access task data.

Highlights

  • Distributed Event Bus Implementation: Introduced a distributed event bus using AWS SNS (Simple Notification Service) for fan-out and SQS (Simple Queue Service) for per-instance event consumption, enabling real-time event delivery across multiple A2A server instances.
  • Persistent Task Store: Implemented a DynamoDB-backed task store (DynamoDBTaskStore) to provide persistent storage for task states, ensuring any server instance can retrieve task information regardless of which instance initially handled it.
  • Optional AWS Dependencies: The new AWS-specific components are designed as optional extras, requiring pip install "a2a-sdk[aws]" to enable them, maintaining a lightweight core SDK for single-process deployments.
  • Queue Lifecycle Management: Added QueueLifecycleManager to automate the provisioning and teardown of per-instance SQS queues and their subscriptions to the shared SNS topic, simplifying deployment in dynamic environments like ECS.
Changelog
  • .gitignore
    • Added .idea directory to the ignore list.
  • pyproject.toml
    • Added 'aioboto3' as an optional 'aws' dependency.
  • src/a2a/server/events/init.py
    • Imported and conditionally exposed new distributed event components, including DistributedEventQueue, QueueLifecycleManager, QueueProvisionResult, and SnsQueueManager.
  • src/a2a/server/events/distributed_event_queue.py
    • Added DistributedEventQueue for publishing events to SNS and handling local delivery without re-broadcasting.
  • src/a2a/server/events/queue_lifecycle_manager.py
    • Added QueueLifecycleManager to manage the lifecycle of per-instance SQS queues and their subscriptions to an SNS topic.
  • src/a2a/server/events/sns_queue_manager.py
    • Added SnsQueueManager as a distributed QueueManager implementation using AWS SNS/SQS for event fan-out and polling.
  • src/a2a/server/tasks/init.py
    • Imported and conditionally exposed DynamoDBTaskStore.
  • src/a2a/server/tasks/dynamodb_task_store.py
    • Added DynamoDBTaskStore for persistent task storage using AWS DynamoDB.
  • tests/server/events/test_distributed_event_queue.py
    • Added unit tests for the DistributedEventQueue class, covering local delivery, SNS publishing, and wire message deserialization.
  • tests/server/events/test_queue_lifecycle_manager.py
    • Added unit tests for the QueueLifecycleManager class, verifying provisioning, teardown, and idempotency.
  • tests/server/events/test_sns_queue_manager.py
    • Added unit tests for the SnsQueueManager class, including event routing, message deduplication, and lifecycle management.
  • tests/server/integration/test_distributed_stack.py
    • Added integration tests for the distributed A2A stack, covering DynamoDB task storage and multi-instance event fan-out.
  • tests/server/tasks/test_dynamodb_task_store.py
    • Added unit tests for the DynamoDBTaskStore class, verifying save, get, and delete operations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant feature for scaling A2A server instances by implementing a persistent task store using DynamoDB and a distributed event bus using AWS SNS/SQS. While the implementation is well-structured, it's crucial to address security concerns related to SQS IAM policy construction, which currently uses string replacement and could be susceptible to policy injection. Furthermore, logging of SQS/SNS message bodies should be restricted to prevent PII leakage, and error handling needs to ensure untrusted input is not included in logged exception messages. My review also includes minor suggestions to improve efficiency and typing for better maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant