Skip to content

Commit 297ec5c

Browse files
jer96jer
andauthored
feat(a2a): configurable request handler (#601)
Co-authored-by: jer <[email protected]>
1 parent bf24ebf commit 297ec5c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/strands/multiagent/a2a/server.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import uvicorn
1212
from a2a.server.apps import A2AFastAPIApplication, A2AStarletteApplication
13+
from a2a.server.events import QueueManager
1314
from a2a.server.request_handlers import DefaultRequestHandler
14-
from a2a.server.tasks import InMemoryTaskStore
15+
from a2a.server.tasks import InMemoryTaskStore, PushNotificationConfigStore, PushNotificationSender, TaskStore
1516
from a2a.types import AgentCapabilities, AgentCard, AgentSkill
1617
from fastapi import FastAPI
1718
from starlette.applications import Starlette
@@ -36,6 +37,12 @@ def __init__(
3637
serve_at_root: bool = False,
3738
version: str = "0.0.1",
3839
skills: list[AgentSkill] | None = None,
40+
# RequestHandler
41+
task_store: TaskStore | None = None,
42+
queue_manager: QueueManager | None = None,
43+
push_config_store: PushNotificationConfigStore | None = None,
44+
push_sender: PushNotificationSender | None = None,
45+
3946
):
4047
"""Initialize an A2A-compatible server from a Strands agent.
4148
@@ -52,6 +59,14 @@ def __init__(
5259
Defaults to False.
5360
version: The version of the agent. Defaults to "0.0.1".
5461
skills: The list of capabilities or functions the agent can perform.
62+
task_store: Custom task store implementation for managing agent tasks. If None,
63+
uses InMemoryTaskStore.
64+
queue_manager: Custom queue manager for handling message queues. If None,
65+
no queue management is used.
66+
push_config_store: Custom store for push notification configurations. If None,
67+
no push notification configuration is used.
68+
push_sender: Custom push notification sender implementation. If None,
69+
no push notifications are sent.
5570
"""
5671
self.host = host
5772
self.port = port
@@ -77,7 +92,10 @@ def __init__(
7792
self.capabilities = AgentCapabilities(streaming=True)
7893
self.request_handler = DefaultRequestHandler(
7994
agent_executor=StrandsA2AExecutor(self.strands_agent),
80-
task_store=InMemoryTaskStore(),
95+
task_store=task_store or InMemoryTaskStore(),
96+
queue_manager=queue_manager,
97+
push_config_store=push_config_store,
98+
push_sender=push_sender,
8199
)
82100
self._agent_skills = skills
83101
logger.info("Strands' integration with A2A is experimental. Be aware of frequent breaking changes.")

0 commit comments

Comments
 (0)