-
Notifications
You must be signed in to change notification settings - Fork 322
Description
What happened?
I'm not sure if this is a bug or a missing description of the feature (or a miss by me to find this documentation).
I'm working on getting support for Push Notifications in my a2a server mozilla-ai/any-agent#414
The way I understand it, the InMemoryPushNotifier has the send_notification method which sends the notification back to all subscribed clients. However, this method is only called from within the DefaultRequestHandler.on_message_send_stream method, it is not used in the on_message call.
Am I trying to use push notifications the wrong way, or is this a bug? It seems like the on_message call should support sending push notifications, to support a scenario like below:
I send a message, subscribe the task for push notifications, and then send another message.
client = await A2AClient.get_client_from_agent_card_url(
httpx_client, server_url
)
# Configure push notifications in the initial message/send request
# following the A2A specification example
first_message_id = str(uuid4())
context_id = str(uuid4())
task_id = str(uuid4())
params = MessageSendParams(
message=Message(
role="user",
parts=[
Part(
kind="text",
text="Generate a Q1 sales report. This usually takes a while. Notify me when it's ready.",
)
],
messageId=first_message_id,
contextId=context_id,
taskId=task_id,
),
configuration=MessageSendConfiguration(
acceptedOutputModes=["text"],
pushNotificationConfig=PushNotificationConfig(url=webhook_url),
),
)
request_1 = SendMessageRequest(id=str(uuid4()), params=params)
response_1 = await client.send_message(request_1)
assert response_1.root.result.id == task_id
push_notification_config = PushNotificationConfig(url=webhook_url)
params_model = TaskPushNotificationConfig(
taskId=task_id, pushNotificationConfig=push_notification_config
)
request_0 = SetTaskPushNotificationConfigRequest(id="", params=params_model)
response_0 = await client.set_task_callback(request_0)
assert not hasattr(response_0, "error")
# now ask the agent a question on the same taskid
request_1 = SendMessageRequest(id=str(uuid4()), params=params)
response_1 = await client.send_message(request_1)
assert response_1.root.result.id == task_id
Thanks!
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct