Repository navigation
Conversation
🧪 Code Coverage (vs
|
There was a problem hiding this comment.
Code Review
This pull request updates the v0.3 compatibility layer by appending the ?alt=sse query parameter to streaming endpoints in rest_transport.py and adding support for the legacy content field as an alias for parts in the Message model. Corresponding unit tests were added to verify these changes. The reviewer suggested avoiding discarding the results of async list comprehensions in tests, recommending instead to store the events for assertions or consume the generator with a loop.
| req = SendMessageRequest( | ||
| message=Message(message_id='msg-1', role=Role.ROLE_USER) | ||
| ) | ||
| _ = [event async for event in transport.send_message_streaming(req)] |
There was a problem hiding this comment.
Using an asynchronous list comprehension solely to consume an async generator creates an unnecessary list in memory. Consider consuming the generator with a simple loop or storing the list of events to assert on them.
| _ = [event async for event in transport.send_message_streaming(req)] | |
| events = [event async for event in transport.send_message_streaming(req)] |
| # Test subscribe | ||
| captured_paths.clear() | ||
| sub_req = SubscribeToTaskRequest(id='task-123') | ||
| _ = [event async for event in transport.subscribe(sub_req)] |
There was a problem hiding this comment.
Using an asynchronous list comprehension solely to consume an async generator creates an unnecessary list in memory. Consider consuming the generator with a simple loop or storing the list of events to assert on them.
| _ = [event async for event in transport.subscribe(sub_req)] | |
| events = [event async for event in transport.subscribe(sub_req)] |
|
I did a quick local verification pass on this PR because it is linked from #1089. Current PR head checked: Results: The formatter-only diff I saw locally was: - assert msg2.parts == [types_v03.Part(root=types_v03.TextPart(text='response'))]
+ assert msg2.parts == [
+ types_v03.Part(root=types_v03.TextPart(text='response'))
+ ]So the failing lint check appears to be fixable by running the repo formatter and pushing the formatted test assertion. The targeted behavior tests still pass after formatting. |
035cdb4 to
71c236b
Compare
325d542 to
da24d49
Compare
da24d49 to
4391fe3
Compare
|
感谢审查!关于测试中丢弃 async list 结果的问题已处理: 测试已重构,不再使用 已 rebase 到最新 upstream/main,CI 全部通过。请再次审查,谢谢! |
Fixes a2aproject#1089 - Response Stream Array-Wrapping Crash 1. Add ?alt=sse parameter to streaming endpoints in rest_transport.py: - /v1/message:stream?alt=sse - /v1/tasks/{id}:subscribe?alt=sse This forces Google A2A API to return SSE format instead of JSON array-wrapped streams that cause protobuf Parse errors. 2. Add AliasChoices for 'content' field in Message class (types.py): - Accepts both 'parts' (v1.0) and 'content' (v0.3) field names - Fixes ValidationError when parsing v0.3 wire format responses Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4391fe3 to
57663f1
Compare
|
Hi @ishymko — this has been open since May, so before doing anything with it: given that 1.0 media-type validation has since landed and the v0.3 compat layer is in maintenance mode, is the If yes, I'll rebase and refresh this. If it's no longer relevant (or the fix belongs elsewhere), say the word and I'll close it — no hard feelings either way. Planning to close it in ~two weeks if there's no signal, just to keep the queue honest. |
|
Hey @Linux2010, thanks for the ping, I no longer actively maintain the repo, let me redirect this. |
|
Following up on the redirect above — @ishymko indicated he's no longer actively maintaining the repo, so re-raising this with the current maintainer team: @rohityan does the v0.3 compat layer still want the If the answer is "the 1.0 media-type validation direction makes this moot" or "v0.3 compat is frozen for new surface", I'll close this PR and the underlying question can live on #1089. Just need a direction to keep the queue honest. |
Summary
Fixes #1089 - Response Stream Array-Wrapping Crash (Transport Layer Mismatch)
Changes
Add
?alt=sseparameter to streaming endpoints (rest_transport.py):/v1/message:stream?alt=sse/v1/tasks/{id}:subscribe?alt=sseThis forces Google A2A API to return SSE format instead of JSON array-wrapped streams that cause
protobuf.json_format.ParseError.Add
AliasChoicesforcontentfield (types.py):Message.partsnow accepts both'parts'(v1.0) and'content'(v0.3) field namesValidationError: parts Field requiredwhen parsing v0.3 wire format responsesTest Plan
test_message_content_aliasto verify content/parts alias mappingtest_compat_rest_transport_stream_url_has_alt_sse_paramto verify SSE URL parameter🤖 Generated with Claude Code
Validation after merging upstream
./scripts/lint.shpassed (three existingtyunused-ignore warnings).uv run pytest: 2,623 passed, 215 skipped, 4 xfailed, 1 xpassed.uv run pytest --cov=src --cov-report=term-missing: same results, 94% coverage.b2967d7.