chore: merge proto refactor into 1.0-dev#697
Conversation
## Summary This PR migrates the a2a-python SDK from Pydantic-based types to protobuf-generated types, completing the upgrade to A2A v1.0. Fixes #559 ## Breaking Changes - Replace Pydantic-based type system with protobuf types from `a2a_pb2` - Update `Part` usage from `Part(root=TextPart(text=...))` to `Part(text=...)` - Update `Role` enum from `Role.user`/`Role.agent` to `Role.ROLE_USER`/`Role.ROLE_AGENT` - Update `TaskState` enum to use `TASK_STATE_*` prefix ## Changes - Update all source files to use proto types directly from `a2a_pb2` - Replace `model_dump()` with `MessageToDict()` for JSON serialization - Replace `model_copy(deep=True)` with `CopyFrom()` for proto cloning - Add new types module with proto imports and SDK-specific extras - Add `proto_utils` module with identity conversion utilities - Fix REST handler resource name formats for push notification configs - Fix gRPC handler to use `SubscribeToTask` instead of `TaskSubscription` - Fix database task store to handle proto objects from ORM - Update all test files for proto patterns and assertions - Fix spelling check failures by updating allow list - Fix inclusive language check failures: - Replace `master` with `main` in documentation - Rename `Dummy` classes to `Mock` in tests ## Testing - **601 tests passing** - 23 tests skipped (expected - require DB connections or cryptography deps) ## Related Builds on top of PR #556 Release-As: 1.0.0 --------- Signed-off-by: Luca Muscariello <muscariello@ieee.org> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com> Co-authored-by: Lukasz Kawka <luk.kawka@gmail.com> Co-authored-by: Agent2Agent (A2A) Bot <a2a-bot@google.com> Co-authored-by: Didier Durand <2927957+didier-durand@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Iva Sokolaj <102302011+sokoliva@users.noreply.github.com> Co-authored-by: Will Chen <36873565+chenweiyang0204@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Description
Updates the SDK to support the A2A Protocol v1.0.0-rc specifications.
## Changes
- **Protocol Update**: Updated core types, definitions, `Client`, and
`Server` implementations to match Protocol v1.0.0-rc.
- **Bug Fixes**:
- Fixed `RestTransport` URL construction.
- Resolved `pyright`, `ruff`, and `mypy` linting errors across the
codebase.
- Fixed import resolution issues for optional dependencies (`grpc`,
`sqlalchemy`, `opentelemetry`).
- **Tests**:
- Fixed all failing unit and integration tests.
- Added support for running PostgreSQL and MySQL integration tests
(verified locally).
- **Cleanup**: Removed redundant `pyrightconfig.json`.
## Testing
- All unit and integration tests are passing.
- Database integration tests verified locally with Docker containers
(docker-compose file was used for verification but is not included in
the repo).
Re #559
---------
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
03ba6d9 to
7f51011
Compare
Summary of ChangesHello @ishymko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a foundational refactor by transitioning the A2A SDK's internal data models from Pydantic to native Protobuf messages. This change streamlines data serialization and deserialization across client and server components, standardizes the API definitions, and modernizes the code generation pipeline. The update affects nearly all layers of the SDK, from core type definitions and client-server communication to build processes and dependency management, aiming for improved performance and consistency with gRPC standards. Highlights
Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
7f51011 to
9727f48
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a significant refactor of the A2A SDK, transitioning from Pydantic-based models to Protobuf-generated types for core protocol entities. This change aligns the Python SDK with the official A2A specification and improves interoperability with other language implementations. The refactor includes updates to client transports (gRPC, JSON-RPC, REST), server request handlers, and task management logic. While the overall structure is sound, I have identified a critical inconsistency in the JSONRPCHandler.list_tasks method which returns a proto object instead of a dictionary, potentially breaking JSON-RPC responses. I've also suggested improvements for error handling in fallthrough cases and noted a minor typo in the documentation.
| # Should we handle this fallthrough? | ||
| pass | ||
|
|
There was a problem hiding this comment.
The fallthrough case where task_or_message is neither a Task nor a Message should be handled by raising an error. Returning an empty response might lead to unexpected behavior or silent failures on the client side.
else:
raise ServerError(
error=InvalidAgentResponseError(
message=f'Handler returned unexpected type: {type(task_or_message)}'
)
)There was a problem hiding this comment.
FYI I am going to review it further, current goal was to resolve merge conflicts and have tests passing, I will dive into the actual changes and will review Gemini comments from this PR.
| (Follow the onscreen instructions to export DSNs and run pytest manually). | ||
|
|
||
| In case of failures, you can clean up the cache: | ||
| In case of failures, you can clean up the cache: |
Fixes #697 (comment), bad merge in #696. Cover "list tasks" in client-server integration tests which would prevent it. Re #559.
JSON-RPC diverged a bit, update it to match other transports. Domain request handler returns `Task | Message` from `on_message_send` already. Fixes #697 (comment). Re #559.
Merge proto refactor into 1.0-dev.
This will apply changes from #572 and #665 on top of
1.0-devpreviously synchronized withmain.See #696 for the diff from
1.0-devapplied on top of proto refactor.Re #559
FYI
I am going to review it further, current goal was to resolve merge conflicts and have tests passing, I will dive into the actual changes and will review Gemini comments from this PR.