Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/a2a/server/request_handlers/default_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,8 @@ async def _setup_message_execution(
# dictating the task ID at this layer is useful for tracking running
# agents.

if (
self._push_config_store
and params.configuration
and params.configuration.task_push_notification_config
if self._push_config_store and params.configuration.HasField(
'task_push_notification_config'
):
await self._push_config_store.set_info(
task_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ async def _setup_active_task(
task_id = cast('str', request_context.task_id)
context_id = cast('str', request_context.context_id)

if (
self._push_config_store
and params.configuration
and params.configuration.task_push_notification_config
if self._push_config_store and params.configuration.HasField(
'task_push_notification_config'
):
await self._push_config_store.set_info(
task_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,36 @@ async def test_on_message_send_with_push_notification():
)


@pytest.mark.asyncio
async def test_on_message_send_with_empty_push_notification_config_does_not_call_set_info():
task_store = InMemoryTaskStore()
push_store = AsyncMock(spec=PushNotificationConfigStore)

request_handler = DefaultRequestHandlerV2(
agent_executor=HelloAgentExecutor(),
task_store=task_store,
push_config_store=push_store,
agent_card=create_default_agent_card(),
)
# Use empty SendMessageConfiguration where task_push_notification_config is NOT set explicitly.
# Proto3 makes accessing it return a truthy default instance.
params = SendMessageRequest(
message=Message(
role=Role.ROLE_USER,
message_id='msg_push_empty',
parts=[Part(text='Hi')],
),
configuration=SendMessageConfiguration(),
)

context = create_server_call_context()
result = await request_handler.on_message_send(params, context)

assert result is not None
assert isinstance(result, Task)
push_store.set_info.assert_not_called()


class MultipleMessagesAgentExecutor(AgentExecutor):
"""Misbehaving agent that yields more than one Message."""

Expand Down
Loading