Repository navigation
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/compat/v0_3/grpc_transport.py | 88.27% | 92.22% | 🟢 +3.94% |
| src/a2a/compat/v0_3/jsonrpc_transport.py | 79.63% | 80.45% | 🟢 +0.82% |
| src/a2a/compat/v0_3/proto_utils.py | 91.14% | 91.51% | 🟢 +0.37% |
| src/a2a/compat/v0_3/rest_transport.py | 96.00% | 96.09% | 🟢 +0.09% |
| src/a2a/utils/task.py | 96.55% | 98.85% | 🟢 +2.30% |
| Total | 94.12% | 94.23% | 🟢 +0.11% |
Generated by coverage-comment.yml
| @@ -0,0 +1,167 @@ | |||
| """A v0.3 agent cannot be asked for an empty history, so the compat transports | |||
There was a problem hiding this comment.
Please split the tests into existing test_{grpc,jsonrpc,rest}_transport.py instead of creating test_history_length_compat.py
| return {'id': '0', 'jsonrpc': '2.0', 'result': result} | ||
|
|
||
|
|
||
| def _rest_transport() -> CompatRestTransport: |
There was a problem hiding this comment.
When working on test_{grpc,jsonrpc,rest}_transport.py, please re-use existing fixtures, to avoid duplication of setup
| TRANSPORTS = [_rest_transport, _jsonrpc_transport, _grpc_transport] | ||
|
|
||
|
|
||
| class TestCompatGetTaskHistoryLength: |
There was a problem hiding this comment.
It's worth adding a test for edge case N >= len(history)
|
The streaming path has the same gap. With history_length 0, send_message_streaming still yields the leading Task with the full history in all three transports. The v1.0 server trims streamed Tasks (default_request_handler_v2.py:561), so the client should match. This fixed it for me in REST, JSON-RPC and gRPC, and tests/compat passes: if event.HasField('task'):
event.task.CopyFrom(
apply_history_length(event.task, request.configuration)
)
yield event |
AI-assisted fix with transport regression tests.
…on and path tests
ConnorMoss02
left a comment
There was a problem hiding this comment.
I checked this against the history_length fixes already on main. #1306, #1312 and #1364 are all server side, where a v0.3 request comes in and 0 or unset becomes unlimited. This covers the other direction, a v1.0 client talking to a v0.3 agent, and nothing on main trims there yet, so it isn't a duplicate. Since v0.3 has no way to ask for an empty history, trimming the result locally is the right call, and it matches what the v1.0 server does for streamed tasks in default_request_handler_v2.py. Merged onto current main it's clean, and tests/compat and tests/client pass.
The description still points at test_history_length_compat.py and doesn't mention streaming. Worth updating so it matches what's in the diff now.
| return a2a_pb2.SendMessageResponse( | ||
| task=conversions.to_core_task( | ||
| proto_utils.FromProto.task(resp_proto.task) | ||
| task=apply_history_length( |
There was a problem hiding this comment.
This one isn't covered. If I drop the apply_history_length here, tests/compat still passes. REST and JSON-RPC both have a test_send_message_history_length; a gRPC one next to test_get_task_history_length would close it.
A v0.3 agent cannot be asked for an empty history, so the compat transports have to apply the v1.0
history_lengthsemantics to the task they return.Background
The two protocol versions disagree on
history_length = 0:0truncates the history to zero items; unlimited requires the field to be left unset (apply_history_lengthinsrc/a2a/utils/task.py).0means unlimited. The repo already encodes this rule and tests it intests/compat/v0_3/test_proto_utils.py::test_message_send_configuration_history_length("A v0.3 history_length of 0 means unlimited, as in task_query_params"), andproto_utils.FromProto.task_query_params/FromProto.message_send_configurationalready normalise0toNone.The gap
The compat client transports forward the caller's
history_lengthto the v0.3 agent verbatim and then return whatever comes back:rest_transport.get_tasksendsparams['historyLength'] = request.history_lengthjsonrpc_transport.get_task/send_messagesend the value produced byto_compat_get_task_request/to_compat_send_message_configurationgrpc_transport.get_tasksendshistory_length=request.history_lengthSo a v1.0 caller that asks for
history_length = 0(i.e. no history) gets the entire history back from a v0.3 agent - the exact opposite of the request.history_length = N > 0happens to work only because the v0.3 agent also does the truncation.This is the outbound direction (v1.0 caller -> v0.3 agent). The inbound direction (v0.3 request -> v1.0 handler) is a separate fix in
to_core_get_task_request/to_core_send_message_configuration, already covered by #1312, so this PR deliberately does not touch it.Fix
Apply the existing
apply_history_lengthhelper to the converted task inget_taskandsend_messageof the three compat transports. This is done on the result rather than on the request because v0.3 has no representation for "no history" - the transports ask for everything and then honour the v1.0 contract locally.history_length0N > 0Tests
tests/compat/v0_3/test_history_length_compat.pycoversget_taskfor all three transports withhistory_lengthof0,1and unset, plussend_messagefor REST and JSON-RPC. Reverting the source change fails 8 of the 11 new tests; the 3 "unset keeps history" cases pass both ways and act as the control.Full suite:
uv run pytest-> 2286 passed, 183 skipped, 3 xfailed, 1 xpassed. The 4 errors undertests/integration/cross_version/client_server/are environmental: they pass in isolation both with and without this change.ruff checkandruff format --checkare clean.AI disclosure
This change was produced with AI assistance and was checked against the specification and the existing tests cited above.
Follow-up verification (2026-10-25)
Addressed review by placing history-length regressions in the existing REST, JSON-RPC and gRPC transport suites, reusing HTTP transport fixtures, and covering N equal to and greater than the history size. Repository lint passed; full suite: 2304 passed, 183 skipped, 3 xfailed, 1 xpassed. Prepared with AI assistance.