Repository navigation
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/compat/v0_3/grpc_transport.py | 63.64% | 65.73% | 🟢 +2.10% |
| src/a2a/compat/v0_3/jsonrpc_transport.py | 73.62% | 74.04% | 🟢 +0.43% |
| src/a2a/compat/v0_3/proto_utils.py | 90.57% | 90.94% | 🟢 +0.37% |
| Total | 92.99% | 93.05% | 🟢 +0.06% |
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 |
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.