refactor(server)!: migrate from Application wrappers to Starlette route-based endpoints for rest#892
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…_json_rpc_server' into guglielmoc/refactor_json_rpc_server
…ssage/task handling, agent cards, and optional v0.3 compatibility.
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 refactors the REST server architecture by moving away from encapsulating REST endpoints within a dedicated FastAPI application wrapper. Instead, it introduces a new utility function, Highlights
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. Footnotes
|
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/request_handlers/rest_handler.py | 93.75% | 91.67% | 🔴 -2.08% |
| src/a2a/server/routes/rest_routes.py (new) | — | 77.11% | — |
| Total | 91.43% | 91.37% | 🔴 -0.06% |
Generated by coverage-comment.yml
There was a problem hiding this comment.
Code Review
This pull request refactors the REST application setup by removing the A2ARESTFastAPIApplication class and introducing a new create_rest_routes function. This change streamlines the creation of REST endpoints, including v0.3 compatibility, and integrates them directly with Starlette applications. The vertex_task_converter.py file was updated to align with vertexai.types for task states and parts, removing google.genai dependencies. Additionally, several test files were updated to reflect these changes. Review comments suggest simplifying the _handle_authenticated_agent_card logic in rest_routes.py and removing an unused Middleware import in test_jsonrpc_routes.py.
Description
This PR refactors the rest server implementation to expose Starlette Route components directly (via RestRoutes) instead of requiring full FastAPI or Starlette application wrappers.
Ref #797 🦕