Skip to content

Commit 9e2b3b2

Browse files
committed
add push for blocking
1 parent 4706c68 commit 9e2b3b2

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
from a2a.types import (
2424
InternalError,
2525
Message,
26+
MessageSendConfiguration,
2627
MessageSendParams,
28+
PushNotificationConfig,
2729
Task,
2830
TaskIdParams,
2931
TaskNotFoundError,
@@ -123,12 +125,10 @@ async def on_message_send(
123125
task: Task | None = await task_manager.get_task()
124126
if task:
125127
task = task_manager.update_with_message(params.message, task)
126-
if (
127-
self._push_notifier
128-
and params.configuration
129-
and params.configuration.pushNotificationConfig
130-
and not params.configuration.blocking
131-
):
128+
if self.should_add_push_info(params):
129+
assert isinstance(self._push_notifier, PushNotifier) # For typechecker
130+
assert isinstance(params.configuration, MessageSendConfiguration) # For typechecker
131+
assert isinstance(params.configuration.pushNotificationConfig, PushNotificationConfig) # For typechecker
132132
await self._push_notifier.set_info(
133133
task.id, params.configuration.pushNotificationConfig
134134
)
@@ -190,11 +190,10 @@ async def on_message_send_stream(
190190
if task:
191191
task = task_manager.update_with_message(params.message, task)
192192

193-
if (
194-
self._push_notifier
195-
and params.configuration
196-
and params.configuration.pushNotificationConfig
197-
):
193+
if self.should_add_push_info(params):
194+
assert isinstance(self._push_notifier, PushNotifier) # For typechecker
195+
assert isinstance(params.configuration, MessageSendConfiguration) # For typechecker
196+
assert isinstance(params.configuration.pushNotificationConfig, PushNotificationConfig) # For typechecker
198197
await self._push_notifier.set_info(
199198
task.id, params.configuration.pushNotificationConfig
200199
)
@@ -319,3 +318,13 @@ async def on_resubscribe_to_task(
319318
consumer = EventConsumer(queue)
320319
async for event in result_aggregator.consume_and_emit(consumer):
321320
yield event
321+
322+
def should_add_push_info(self, params: MessageSendParams) -> bool:
323+
if (
324+
self._push_notifier
325+
and params.configuration
326+
and params.configuration.pushNotificationConfig
327+
):
328+
return True
329+
else:
330+
return False

0 commit comments

Comments
 (0)