Add your description here
Project description
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:
- DistributedAgentExecutor (Client Side): Used by the A2A server to enqueue agent execution tasks into a distributed queue.
- 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 anyDistributedAgentWorkerwith 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file a2a_distributed-0.0.0.tar.gz.
File metadata
- Download URL: a2a_distributed-0.0.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce024e416cf3459563cbdea12e2b797341410e3791d9c1265a9be381fdb50ae6
|
|
| MD5 |
4980b5925d5e7efd4d272e6f973de93f
|
|
| BLAKE2b-256 |
28c595b7b4d6f5d186205543afbe0648f47fa3de9b6a00ceddd8947b5a1ca13b
|
File details
Details for the file a2a_distributed-0.0.0-py3-none-any.whl.
File metadata
- Download URL: a2a_distributed-0.0.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4efb10069af71e8c4545c4c7b35fb74de5cf160ba0c9694117efeac4a886adb
|
|
| MD5 |
2be6678ac3cc094f43801842f21c0f56
|
|
| BLAKE2b-256 |
bfc5d23ab26a0b2ff8ec72f39bd5fc305abc2bf5a9a68739f296fc85dce8b99b
|