feat: Keep only 0.3 compatible endpoints in compat version of AgentCard #846
feat: Keep only 0.3 compatible endpoints in compat version of AgentCard #846
Conversation
Summary of ChangesHello, 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 significantly enhances the A2A SDK's ability to interoperate with different protocol versions, particularly focusing on backward compatibility with v0.3 endpoints. It transitions the core data structures to Protocol Buffers for improved robustness and introduces a robust database migration system. The changes ensure that both client and server components can gracefully handle requests from various protocol versions, laying the groundwork for future extensibility and stability. 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
|
686643b to
2768904
Compare
There was a problem hiding this comment.
Code Review
This pull request effectively ensures backward compatibility with v0.3 of the A2A protocol by filtering agent card interfaces. The refactoring of the legacy version check into a shared utility function is a solid improvement for code reuse and maintainability. The core logic change in to_compat_agent_card is well-implemented, including robust error handling for cases where no compatible interfaces are found. The accompanying tests are thorough and provide excellent coverage for the new functionality and edge cases. I've added a few minor suggestions to further improve code clarity and consistency in the tests.
I am having trouble creating individual review comments. Click here to see my feedback.
tests/compat/v0_3/test_rest_transport.py (304-307)
This nested if method == 'POST' check is redundant, as the outer if statement on line 303 already confirms that method is 'POST'. Consequently, the else branch on line 306 is unreachable. You can simplify this block by removing the inner conditional.
assert json == {'id': 'task-123'}tests/compat/v0_3/test_conversions.py (989-991)
To improve maintainability and consistency with the implementation, consider using the constants.PROTOCOL_VERSION_0_3 constant here instead of the hardcoded string '0.3'. This ensures the test remains aligned with the implementation if the constant's value ever changes. You will need to add from a2a.utils import constants at the top of the file.
v10_expected = pb2_v10.AgentInterface(
url='http', protocol_binding='JSONRPC', protocol_version=constants.PROTOCOL_VERSION_0_3
)
tests/compat/v0_3/test_conversions.py (1134-1136)
Similar to the previous comment, using the constants.PROTOCOL_VERSION_0_3 constant here would improve consistency and maintainability.
pb2_v10.AgentInterface(
url='u2', protocol_binding='HTTP', protocol_version=constants.PROTOCOL_VERSION_0_3
),
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/client_factory.py | 88.89% | 89.35% | 🟢 +0.46% |
| src/a2a/server/request_handlers/response_helpers.py | 95.52% | 95.71% | 🟢 +0.19% |
| src/a2a/compat/v0_3/versions.py (new) | — | 100.00% | — |
| Total | 89.98% | 90.02% | 🟢 +0.04% |
Generated by coverage-comment.yml
Fixes #742