fix: align send_message signature for Client and BaseClient (#727)#739
fix: align send_message signature for Client and BaseClient (#727)#739Akshat8510 wants to merge 36 commits intoa2aproject:mainfrom
Conversation
Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Luca Muscariello <muscariello@ieee.org> Co-authored-by: Yaroslav <yarolegovich@gmail.com> Co-authored-by: Agent2Agent (A2A) Bot <a2a-bot@google.com> Co-authored-by: agil.yolchuyev <agilyolchuyev@outlook.com> Co-authored-by: yolagil <agil@peotic.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Co-authored-by: Luca Muscariello <muscariello@ieee.org> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…the specification (a2aproject#511) Commit: a2aproject/A2A@0a9f629 This PR introduces support for the new `tasks/list` method, including: - Automatically generated type definitions from the specification. - Complete client-side and server-side implementations. Fixes a2aproject#515 🦕 --------- Co-authored-by: lkawka <lkawka@google.com> Co-authored-by: lkawka <luk.kawka@gmail.com> Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
Co-authored-by: Iva Sokolaj <102302011+sokoliva@users.noreply.github.com> Co-authored-by: Agent2Agent (A2A) Bot <a2a-bot@google.com> Co-authored-by: Tadaki Asechi <127199356+TadakiAsechi@users.noreply.github.com> Co-authored-by: tadaki <tadaki.asechi@gmail.com> Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Co-authored-by: TadakiAsechi <tadaki.asechi@icould.com> Co-authored-by: TadakiAsechi <tadaki.asechi@iclould.com>
## Summary This PR migrates the a2a-python SDK from Pydantic-based types to protobuf-generated types, completing the upgrade to A2A v1.0. Fixes a2aproject#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 a2aproject#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 Do not use `NULLS LAST` which is not available in MySQL, coalesce nulls to empty strings which will appear last in descending ordering (there are tests for this behavior already, however CI wasn't enabled for this branch). Currently `NULLS LAST` fails MySQL tests: ``` (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULLS LAST, tasks.id DESC \n LIMIT 51' at line 3") ``` ([actions run](https://github.com/a2aproject/a2a-python/actions/runs/21520017047/job/62008309612?pr=651)) Enable tests run against `1.0-dev` to prevent it in the future. Re a2aproject#511 Fixes a2aproject#652 --- Mark as "refactor" for release please as it's a fix for a non-released feature, hence shouldn't get into a changelog. BEGIN_COMMIT_OVERRIDE refactor: use MySQL compatible syntax in list tasks END_COMMIT_OVERRIDE
# Conflicts: # CHANGELOG.md # tests/client/transports/test_rest_client.py # tests/utils/test_proto_utils.py
# Description Merge `main` into `1.0-dev` through an intermediate branch to resolve conflicts. Opening a PR from `main` to `1.0-dev` required pushing to `main` to resolve conflicts. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Iva Sokolaj <102302011+sokoliva@users.noreply.github.com> Co-authored-by: Agent2Agent (A2A) Bot <a2a-bot@google.com> Co-authored-by: Tadaki Asechi <127199356+TadakiAsechi@users.noreply.github.com> Co-authored-by: tadaki <tadaki.asechi@gmail.com> Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com> Co-authored-by: TadakiAsechi <tadaki.asechi@icould.com> Co-authored-by: TadakiAsechi <tadaki.asechi@iclould.com> Co-authored-by: ShishirRmc <113575088+ShishirRmc@users.noreply.github.com> Co-authored-by: Lukasz Kawka <luk.kawka@gmail.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: Will Chen <36873565+chenweiyang0204@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Vinay Ramesh <vinay.r.ramesh@gmail.com>
# Description Run linter on `1.0-dev`.
This reverts commit 40613ed. Should be merged without squashing
…#665) ## 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 a2aproject#559 --------- Signed-off-by: Luca Muscariello <muscariello@ieee.org>
To resolve existing merge issues first.
Fixes a2aproject#697 (comment), bad merge in a2aproject#696. Cover "list tasks" in client-server integration tests which would prevent it. Re a2aproject#559.
Bring back `.pre-commit-config.yaml` and disabled JSCPD linter. Removal can be evaluated separately, for now bringing them back to make diff against `main` more focused. Re a2aproject#559.
Tests basic functionality with real client and server with real handlers, only agent executor is provided in test as it'd be in a real usage. Re a2aproject#559
JSON-RPC diverged a bit, update it to match other transports. Domain request handler returns `Task | Message` from `on_message_send` already. Fixes a2aproject#697 (comment). Re a2aproject#559.
According to [the spec](https://a2a-protocol.org/latest/specification/#314-list-tasks) all response fields are mandatory. Update implementation and add tests to cover. Re a2aproject#515
Active updates are happening to [A2A repo](https://github.com/a2aproject/A2A/commits/main/) currently. Switch `buf.gen.yaml` back to `main` (a2aproject#699 switched it to the 1.0 RC tag to progress with merge without regenerating files) and update code to work with the latest changes. Re a2aproject#559.
Following > The operation MUST return a Task object as the first event in the stream introduced in 1.0: https://a2a-protocol.org/latest/specification/#316-subscribe-to-task It also correctly uses `UnsupportedOperationError` as per the "Errors" section from the documentation linked above. Fixes a2aproject#675 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
According to https://a2a-protocol.org/latest/specification/#324-history-length-semantics. It changes behavior so the fix was postponed till 1.0. After changing to proto passing `.history_length` would not work anymore due to the way how proto generated code works - optional values are still translated to language defaults to avoid `None`s, while presence should be checked via `HasField` - done in this PR. Fixes a2aproject#573 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
# Description See [here](https://a2a-protocol.org/latest/specification/#validation-error-example) and [3.1.4. List Tasks](https://a2a-protocol.org/latest/specification/#314-list-tasks). Re a2aproject#515
## Description As per the 1.0 spec update (see [4.3.3. Push Notification Payload](https://a2a-protocol.org/latest/specification/#433-push-notification-payload)) use `StreamResponse` as push notifications payload. Fixes a2aproject#678 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Use enum everywhere, data model uses `str` for protocol names, so custom protocols won't be constrained with the enum. Fixes a2aproject#705
…ject#732) Rely on the `ClientFactory` to resolve proper URL and do not duplicate logic in transports. `AgentCard` is still passed to transports as it's used for capabilities inspection. Make both `agent_card` and `url` mandatory, transports are mainly used from the `ClientFactory` and `| None` are likely non-breaking leftovers. Fixes a2aproject#703
According to the [npx docs](https://docs.npmjs.com/cli/v8/commands/npx): > If any requested packages are not present in the local project dependencies, then they are installed to a folder in the npm cache, which is added to the PATH environment variable in the executed process. A prompt is printed (which can be suppressed by providing either --yes or --no). Running it in non-interactive manner hangs build process and waits for keyboard input. See a2aproject#706 for potential long-term solution. Was originally added in a2aproject#696.
# Description - Test artifacts. - Add more assertions for streaming: validate all events. - Fix non-streaming tests which were actually streaming.
Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
Summary of ChangesHello @Akshat8510, 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 introduces a fundamental shift in how A2A protocol types are handled within the Python SDK, moving from Pydantic models to native Protobuf messages. This change impacts both client and server components, ensuring a more robust and consistent API experience. The update also refines the type generation process, consolidates generated files, and enhances error handling mechanisms, contributing to a more maintainable and performant codebase. 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
|
There was a problem hiding this comment.
Code Review
This is an extensive and well-executed refactoring to migrate the project's data models from Pydantic to Protobuf. The changes are consistent across the entire codebase, including client, server, and test files. This move simplifies the architecture by removing the proto_utils conversion layer, improves type safety, and aligns the project with the A2A specification as the single source of truth for data models. The automation of code generation via buf and hatch build hooks is a great addition. The cleanup of legacy clients and scripts is also a welcome improvement. Overall, this is a high-quality pull request that significantly improves the maintainability and robustness of the SDK. The one minor issue identified is still valid.
| missing_padding = len(encoded_str) % 4 | ||
| if missing_padding: | ||
| encoded_str += '=' * (4 - missing_padding) | ||
| print(f'input: {encoded_str}') |
Aligned the
send_messagesignature inClientwithBaseClient.Note: I used
SendMessageConfiguration(instead ofMessageSendConfigurationmentioned in the issue) becauseSendMessageConfigurationis the correct attribute name found ina2a_pb2, as verified bymypy.Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.bash scripts/format.shfrom the repository root to format)Fixes #727 🦕