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
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: v2
inputs:
- git_repo: https://github.com/a2aproject/A2A.git
ref: aca981cee3e7a3f22a4df8fb8a5302406f7a1cf5
ref: main
subdir: specification
managed:
enabled: true
Expand Down
3 changes: 1 addition & 2 deletions src/a2a/client/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ async def send_message(
yield client_event

def _apply_client_config(self, request: SendMessageRequest) -> None:
if not request.configuration.blocking and self._config.polling:
request.configuration.blocking = not self._config.polling
request.configuration.return_immediately |= self._config.polling
if (
not request.configuration.HasField('task_push_notification_config')
and self._config.push_notification_configs
Expand Down
10 changes: 3 additions & 7 deletions src/a2a/compat/v0_3/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ def to_core_send_message_configuration(
) -> pb2_v10.SendMessageConfiguration:
"""Convert send message configuration to v1.0 core type."""
core_config = pb2_v10.SendMessageConfiguration()
core_config.blocking = (
True # Default to True as per A2A spec for SendMessage
)
# Result will be blocking by default (return_immediately=False)
if compat_config.accepted_output_modes:
core_config.accepted_output_modes.extend(
compat_config.accepted_output_modes
Expand All @@ -320,7 +318,7 @@ def to_core_send_message_configuration(
if compat_config.history_length is not None:
core_config.history_length = compat_config.history_length
if compat_config.blocking is not None:
core_config.blocking = compat_config.blocking
core_config.return_immediately = not compat_config.blocking
return core_config


Expand All @@ -340,7 +338,7 @@ def to_compat_send_message_configuration(
history_length=core_config.history_length
if core_config.HasField('history_length')
else None,
blocking=core_config.blocking,
blocking=not core_config.return_immediately,
)


Expand Down Expand Up @@ -1039,8 +1037,6 @@ def to_core_send_message_request(
core_req.configuration.CopyFrom(
to_core_send_message_configuration(compat_req.params.configuration)
)
else:
core_req.configuration.blocking = True # Default for A2A
if compat_req.params.metadata:
ParseDict(compat_req.params.metadata, core_req.metadata)
return core_req
Expand Down
4 changes: 1 addition & 3 deletions src/a2a/server/request_handlers/default_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ async def on_message_send(
consumer = EventConsumer(queue)
producer_task.add_done_callback(consumer.agent_task_callback)

blocking = True # Default to blocking behavior
if params.configuration and params.configuration.blocking is False:
blocking = False
blocking = not params.configuration.return_immediately

interrupted_or_non_blocking = False
Comment thread
ishymko marked this conversation as resolved.
try:
Expand Down
216 changes: 108 additions & 108 deletions src/a2a/types/a2a_pb2.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/a2a/types/a2a_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ ROLE_USER: Role
ROLE_AGENT: Role

class SendMessageConfiguration(_message.Message):
__slots__ = ("accepted_output_modes", "task_push_notification_config", "history_length", "blocking")
__slots__ = ("accepted_output_modes", "task_push_notification_config", "history_length", "return_immediately")
ACCEPTED_OUTPUT_MODES_FIELD_NUMBER: _ClassVar[int]
TASK_PUSH_NOTIFICATION_CONFIG_FIELD_NUMBER: _ClassVar[int]
HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int]
BLOCKING_FIELD_NUMBER: _ClassVar[int]
RETURN_IMMEDIATELY_FIELD_NUMBER: _ClassVar[int]
accepted_output_modes: _containers.RepeatedScalarFieldContainer[str]
task_push_notification_config: TaskPushNotificationConfig
history_length: int
blocking: bool
def __init__(self, accepted_output_modes: _Optional[_Iterable[str]] = ..., task_push_notification_config: _Optional[_Union[TaskPushNotificationConfig, _Mapping]] = ..., history_length: _Optional[int] = ..., blocking: _Optional[bool] = ...) -> None: ...
return_immediately: bool
def __init__(self, accepted_output_modes: _Optional[_Iterable[str]] = ..., task_push_notification_config: _Optional[_Union[TaskPushNotificationConfig, _Mapping]] = ..., history_length: _Optional[int] = ..., return_immediately: _Optional[bool] = ...) -> None: ...

class Task(_message.Message):
__slots__ = ("id", "context_id", "status", "artifacts", "history", "metadata")
Expand Down
7 changes: 3 additions & 4 deletions tests/client/test_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ async def test_send_message_callsite_config_overrides_non_streaming(

cfg = SendMessageConfiguration(
history_length=2,
blocking=False,
return_immediately=True,
accepted_output_modes=['application/json'],
)
request = SendMessageRequest(message=sample_message, configuration=cfg)
Expand All @@ -249,7 +249,7 @@ async def test_send_message_callsite_config_overrides_non_streaming(

params = mock_transport.send_message.call_args[0][0]
assert params.configuration.history_length == 2
assert params.configuration.blocking is False
assert params.configuration.return_immediately is True
assert params.configuration.accepted_output_modes == [
'application/json'
]
Expand Down Expand Up @@ -278,7 +278,6 @@ async def create_stream(*args, **kwargs):

cfg = SendMessageConfiguration(
history_length=0,
blocking=True,
accepted_output_modes=['text/plain'],
)
request = SendMessageRequest(message=sample_message, configuration=cfg)
Expand All @@ -292,5 +291,5 @@ async def create_stream(*args, **kwargs):

params = mock_transport.send_message_streaming.call_args[0][0]
assert params.configuration.history_length == 0
assert params.configuration.blocking is True
assert params.configuration.return_immediately is False
assert params.configuration.accepted_output_modes == ['text/plain']
11 changes: 4 additions & 7 deletions tests/compat/v0_3/test_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ def test_send_message_configuration_conversion():
v10_expected = pb2_v10.SendMessageConfiguration(
accepted_output_modes=['text/plain', 'application/json'],
history_length=10,
blocking=True,
task_push_notification_config=pb2_v10.TaskPushNotificationConfig(
url='http://test',
authentication=pb2_v10.AuthenticationInfo(scheme='Basic'),
Expand All @@ -443,7 +442,7 @@ def test_send_message_configuration_conversion():

def test_send_message_configuration_conversion_minimal():
v03_config = types_v03.MessageSendConfiguration()
v10_expected = pb2_v10.SendMessageConfiguration(blocking=True)
v10_expected = pb2_v10.SendMessageConfiguration()

v10_config = to_core_send_message_configuration(v03_config)
assert v10_config == v10_expected
Expand Down Expand Up @@ -1306,9 +1305,7 @@ def test_send_message_request_conversion():
role=pb2_v10.Role.ROLE_USER,
parts=[pb2_v10.Part(text='Hi')],
),
configuration=pb2_v10.SendMessageConfiguration(
history_length=5, blocking=True
),
configuration=pb2_v10.SendMessageConfiguration(history_length=5),
)
ParseDict({'k': 'v'}, v10_expected.metadata)

Expand Down Expand Up @@ -1767,8 +1764,8 @@ def test_to_core_send_message_request_no_configuration():
),
)
core_req = to_core_send_message_request(v03_req)
# Default is True if configuration is absent
assert core_req.configuration.blocking is True
# Blocking by default (return_immediately=False)
assert core_req.configuration.return_immediately is False
assert not core_req.HasField('message')


Expand Down
6 changes: 3 additions & 3 deletions tests/compat/v0_3/test_grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def test_send_message_success_task(
message_id='msg-1', role=a2a_pb2.Role.ROLE_USER
),
configuration=a2a_pb2.SendMessageConfiguration(
history_length=0, blocking=False
history_length=0, return_immediately=True
),
)
mock_request_handler.on_message_send.assert_called_once_with(
Expand Down Expand Up @@ -105,7 +105,7 @@ async def test_send_message_success_message(
message_id='msg-1', role=a2a_pb2.Role.ROLE_USER
),
configuration=a2a_pb2.SendMessageConfiguration(
history_length=0, blocking=False
history_length=0, return_immediately=True
),
)
mock_request_handler.on_message_send.assert_called_once_with(
Expand Down Expand Up @@ -158,7 +158,7 @@ async def mock_stream(*args, **kwargs):
message_id='msg-1', role=a2a_pb2.Role.ROLE_USER
),
configuration=a2a_pb2.SendMessageConfiguration(
history_length=0, blocking=False
history_length=0, return_immediately=True
),
)
mock_request_handler.on_message_send_stream.assert_called_once_with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async def test_notification_triggering_after_config_change_e2e(
parts=[Part(text='How are you?')],
role=Role.ROLE_USER,
),
configuration=SendMessageConfiguration(blocking=True),
configuration=SendMessageConfiguration(),
)
)
]
Expand Down Expand Up @@ -225,7 +225,7 @@ async def test_notification_triggering_after_config_change_e2e(
parts=[Part(text='Good')],
role=Role.ROLE_USER,
),
configuration=SendMessageConfiguration(blocking=True),
configuration=SendMessageConfiguration(),
)
)
]
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ async def test_end_to_end_send_message_blocking(transport_setups):
message_id='msg-e2e-blocking',
parts=[Part(text='Run dummy agent!')],
)
configuration = SendMessageConfiguration(blocking=True)
configuration = SendMessageConfiguration()

events = [
event
Expand Down Expand Up @@ -312,7 +312,7 @@ async def test_end_to_end_send_message_non_blocking(transport_setups):
message_id='msg-e2e-non-blocking',
parts=[Part(text='Run dummy agent!')],
)
configuration = SendMessageConfiguration(blocking=False)
configuration = SendMessageConfiguration(return_immediately=True)

events = [
event
Expand Down
6 changes: 2 additions & 4 deletions tests/server/request_handlers/test_default_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ async def test_on_message_send_with_push_notification_in_non_blocking_request():
message_config = SendMessageConfiguration(
task_push_notification_config=push_config,
accepted_output_modes=['text/plain'],
blocking=False, # Non-blocking request
return_immediately=True,
)
params = SendMessageRequest(
message=Message(
Expand Down Expand Up @@ -932,7 +932,7 @@ async def test_on_message_send_non_blocking():
parts=[Part(text='Hi')],
),
configuration=SendMessageConfiguration(
blocking=False, accepted_output_modes=['text/plain']
return_immediately=True, accepted_output_modes=['text/plain']
),
)

Expand Down Expand Up @@ -978,7 +978,6 @@ async def test_on_message_send_limit_history():
parts=[Part(text='Hi')],
),
configuration=SendMessageConfiguration(
blocking=True,
accepted_output_modes=['text/plain'],
history_length=1,
),
Expand Down Expand Up @@ -1016,7 +1015,6 @@ async def test_on_get_task_limit_history():
parts=[Part(text='Hi')],
),
configuration=SendMessageConfiguration(
blocking=True,
accepted_output_modes=['text/plain'],
),
)
Expand Down
Loading