Skip to content
Open
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: 4 additions & 2 deletions src/a2a/compat/v0_3/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def to_core_send_message_configuration(
compat_config.push_notification_config
)
)
if compat_config.history_length is not None:
# v0.3 treats 0 as unlimited, so leave it unset.
if compat_config.history_length:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add a small comment here (e.g., 0 = unlimited) to make the behavior explicit for future readers and avoid accidental rewrites.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in d18e7b4.

core_config.history_length = compat_config.history_length
if compat_config.blocking is not None:
core_config.return_immediately = not compat_config.blocking
Expand Down Expand Up @@ -1074,7 +1075,8 @@ def to_core_get_task_request(
"""Convert get task request to v1.0 core type."""
core_req = pb2_v10.GetTaskRequest()
core_req.id = compat_req.params.id
if compat_req.params.history_length is not None:
# v0.3 treats 0 as unlimited, so leave it unset.
if compat_req.params.history_length:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in d18e7b4.

core_req.history_length = compat_req.params.history_length
return core_req

Expand Down
14 changes: 14 additions & 0 deletions tests/compat/v0_3/test_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ def test_send_message_configuration_conversion_minimal():
assert v03_restored == v03_expected_restored


def test_send_message_configuration_conversion_history_length_zero():
v03_config = types_v03.MessageSendConfiguration(history_length=0)
v10_config = to_core_send_message_configuration(v03_config)
assert not v10_config.HasField('history_length')


def test_artifact_conversion_full():
v03_artifact = types_v03.Artifact(
artifact_id='a1',
Expand Down Expand Up @@ -1348,6 +1354,14 @@ def test_get_task_request_conversion_minimal():
assert v03_restored == v03_req


def test_get_task_request_conversion_history_length_zero():
v03_req = types_v03.GetTaskRequest(
id='conv', params=types_v03.TaskQueryParams(id='t1', history_length=0)
)
v10_req = to_core_get_task_request(v03_req)
assert not v10_req.HasField('history_length')


def test_cancel_task_request_conversion():
v03_req = types_v03.CancelTaskRequest(
id='conv',
Expand Down
Loading