Skip to main content

a2a-distributed

a2a-distributed provides distributed execution capabilities for A2A agents. It allows you to offload agent execution to background workers using popular task queues like Celery, BullMQ, or RQ (Redis Queue).

Architecture

The package follows a Client/Worker architecture:

  1. DistributedAgentExecutor (Client Side): Used by the A2A server to enqueue agent execution tasks into a distributed queue.
  2. DistributedAgentWorker (Worker Side): A background process that listens to the queue, reconstructs the execution context, and runs the agent using a local AgentExecutor.

Exports

Base Classes

  • DistributedAgentExecutor: Abstract base class for all distributed executors.
  • DistributedAgentWorker: Abstract base class for all distributed workers.

Celery Implementation

  • CeleryAgentExecutor: Enqueues tasks to Celery.
  • CeleryAgentWorker: Handles Celery tasks.

BullMQ Implementation

  • BullMQAgentExecutor: Enqueues jobs to BullMQ.
  • BullMQAgentWorker: Processes BullMQ jobs.

RQ Implementation

  • RQAgentExecutor: Enqueues jobs to Redis Queue.
  • RQAgentWorker: Processes RQ jobs.

Utilities

  • run_worker: A utility function to run any DistributedAgentWorker with built-in signal handling for graceful shutdown.

Usage Example

1. Setting up the Executor (Client Side)

from a2a_distributed import BullMQAgentExecutor

# Initialize the executor with connection options
executor = BullMQAgentExecutor(
    queue_name="agent-tasks",
    redis_opts={"host": "localhost", "port": 6379}
)

# Use it in your A2A server configuration
# server = A2AServer(executor=executor, ...)

2. Setting up the Worker (Worker Side)

import asyncio
from a2a_distributed import BullMQAgentWorker, run_worker
from a2a.server.agent_execution import LocalAgentExecutor
from a2a_redis import RedisEventQueue

async def main():
    # 1. Local executor that actually runs the agent logic
    local_executor = LocalAgentExecutor(...) 
    
    # 2. Event queue for reporting status/results back
    event_queue = RedisEventQueue(...)
    
    # 3. The Distributed Worker
    worker = BullMQAgentWorker(
        agent_executor=local_executor,
        event_queue=event_queue,
        queue_name="agent-tasks",
        redis_opts={"host": "localhost", "port": 6379}
    )
    
    # 4. Run the worker using the utility
    await run_worker(worker)

if __name__ == "__main__":
    asyncio.run(main())

Running Workers

To run a worker, simply call await worker.run() or use the run_worker(worker) utility which handles SIGINT and SIGTERM signals for you.

For Celery and RQ, the workers are often started via their respective CLI tools, but the DistributedAgentWorker classes provided here allow for programmatic control and integration within your own async loops.

Metadata

Release files for a2a-distributed 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2a-distributed 0.0.0
File Size Uploaded
a2a_distributed-0.0.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2a-distributed 0.0.0
File Interpreter ABI Platform
a2a_distributed-0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / a2a_distributed-0.0.0.tar.gz

Download URL a2a_distributed-0.0.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ce024e416cf3459563cbdea12e2b797341410e3791d9c1265a9be381fdb50ae6
BLAKE2b-256 checksum
How to use checksums
28c595b7b4d6f5d186205543afbe0648f47fa3de9b6a00ceddd8947b5a1ca13b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / a2a_distributed-0.0.0-py3-none-any.whl

Download URL a2a_distributed-0.0.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4efb10069af71e8c4545c4c7b35fb74de5cf160ba0c9694117efeac4a886adb
BLAKE2b-256 checksum
How to use checksums
bfc5d23ab26a0b2ff8ec72f39bd5fc305abc2bf5a9a68739f296fc85dce8b99b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page