Skip to content

refactor(server): eliminate Intermediary JSONRPCHandler for direct RequestHandler dispatching#896

Merged
guglielmo-san merged 6 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/refactor_jsonrpc_server
Mar 25, 2026
Merged

refactor(server): eliminate Intermediary JSONRPCHandler for direct RequestHandler dispatching#896
guglielmo-san merged 6 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/refactor_jsonrpc_server

Conversation

@guglielmo-san
Copy link
Member

Description

This branch eliminates the secondary layer of handling (JSONRPCHandler) by transferring dispatching duties immediately to DefaultRequestHandler.

Changes

  • Completely dropped src/a2a/server/request_handlers/jsonrpc_handler.py.

  • Refactored src/a2a/server/routes/jsonrpc_dispatcher.py to target dispatching precisely utilized mapping distinct transmissions natively.

Fixes #797 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 server's JSON-RPC request handling by removing an unnecessary intermediary layer. Previously, JsonRpcDispatcher delegated to JSONRPCHandler, which then called the DefaultRequestHandler. This change allows JsonRpcDispatcher to directly interact with DefaultRequestHandler, simplifying the call stack, improving maintainability, and reducing boilerplate code. The core logic for processing JSON-RPC methods is now consolidated within the dispatcher, making the flow more direct and easier to understand.

Highlights

  • Architectural Refactor: Eliminated the intermediary JSONRPCHandler class, streamlining the request dispatching process.
  • Direct Dispatching: Refactored JsonRpcDispatcher to directly handle JSON-RPC requests by calling methods on DefaultRequestHandler, removing the need for an extra layer of indirection.
  • Code Removal: Removed the jsonrpc_handler.py file and its associated test file, reducing codebase complexity.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Mar 25, 2026

🧪 Code Coverage (vs 1.0-dev)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/request_handlers/default_request_handler.py 96.89% 96.54% 🔴 -0.35%
src/a2a/server/routes/jsonrpc_dispatcher.py 85.78% 86.22% 🟢 +0.44%
Total 91.37% 91.30% 🔴 -0.07%

Generated by coverage-comment.yml

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the JSON-RPC handling by removing the dedicated JSONRPCHandler class and integrating its functionalities directly into the JsonRpcDispatcher. This includes moving request routing, response formatting, error handling, and capability validation logic into the dispatcher's _process_streaming_request and _process_non_streaming_request methods. Parameter names have been updated from http_handler to request_handler for consistency across the codebase and tests. Additionally, integration tests now explicitly set the A2A-Version header. There is no feedback to provide on the review comments as none were provided.

@guglielmo-san guglielmo-san marked this pull request as ready for review March 25, 2026 08:56
@guglielmo-san guglielmo-san requested a review from a team as a code owner March 25, 2026 08:56
@guglielmo-san guglielmo-san requested a review from ishymko March 25, 2026 08:57
@guglielmo-san guglielmo-san requested a review from ishymko March 25, 2026 11:06
@guglielmo-san guglielmo-san enabled auto-merge (squash) March 25, 2026 12:07
@guglielmo-san guglielmo-san merged commit 3d7309a into a2aproject:1.0-dev Mar 25, 2026
9 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/refactor_jsonrpc_server branch March 25, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants