[Feat]: Support JSON-RPC Responses for Decoupled Pub/Sub Push Communication in Message-Driven Architectures

Open
#571 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Look at the primary HTTP 'POST' route in the SDK, likely in a file like server.py or routes.py, and the Pydantic models for JSONRPCRequest and JSONRPCResponse. Understand how the validation currently works. The solution involves modifying the route's input validation to accept a union type or creating a new endpoint. Check existing tests for the route to see how to add tests for the new behavior.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

The current implementation of the A2A Python SDK, when used as an agent in a message-driven architecture (e.g., handling requests pushed via Google Pub/Sub), only validates and accepts JSONRPCRequest objects on its primary HTTP 'POST' route.

In this architecture, an agent receives a request from a message broker (e.g., Pub/Sub push subscription), processes it, acknowledges the broker with a standard HTTP response, and sends the real, decoupled response back to the requesting service's inbound message queue.

If the requesting service is also an agent built with the same A2A Python SDK, it needs to receive a JSONRPCResponse. Since the receiving agent's primary 'POST' route strictly expects a JSONRPCRequest format via the Pydantic model validation, the inbound JSONRPCResponse is rejected, preventing the successful completion of the message exchange.

Describe the solution you'd like

We need to enable the SDK to correctly receive and process JSONRPCResponse objects on an agent, facilitating decoupled, asynchronous, push-based communication.

We propose discussing two possible solutions:

  1. Loosen Model Validation for Combined Input: Modify the Pydantic model validation on the main 'POST' route to accept a combined input of either a JSONRPCRequest or a JSONRPCResponse(e.g., checking against a union type like JSONRPCRequest | JSONRPCResponse). This would allow responses to be delivered via the existing primary request route.
  2. Introduce a Dedicated Response Route: Implement a new, dedicated HTTP endpoint (e.g., /response or /push_response) specifically for receiving and handling decoupled JSONRPCResponse objects.
Describe alternatives you've considered

No response

Additional context

This issue is critical for agents using the A2A Python SDK within environments where asynchronous, Pub/Sub push-based communication is the standard, as it currently blocks the ability to receive the final response successfully.

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
Python
Stars
2.2k
Forks
496
Avg merge
1d 23h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from a2aproject/a2a-python

All issues in a2aproject/a2a-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.