这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: Update json names of gRPC objects for proper transcoding #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 8, 2025

Conversation

pstephengoogle
Copy link
Contributor

Update json names of gRPC objects for proper transcoding

@pstephengoogle pstephengoogle requested a review from a team as a code owner July 8, 2025 17:15
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.

Summary of Changes

Hello @pstephengoogle, 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 focuses on enhancing the consistency and clarity of API definitions, primarily by refining the JSON transcoding behavior of gRPC objects. It standardizes field naming conventions across gRPC protobufs, JSON schemas, and TypeScript types, and introduces new documentation to provide a clearer understanding of the supported API transport structures.

Highlights

  • gRPC JSON Naming Consistency: Explicitly set json_name options for the update field in TaskStatus and the msg field in SendMessageResponse and StreamResponse protobuf messages. This ensures these fields are correctly transcoded to 'message' in their JSON representations, aligning with expected JSON output.
  • JSON Schema and TypeScript Type Alignment: Renamed the additionalInterfaces field to additional_interfaces in the AgentCard definition within both the a2a.json schema and the types.ts TypeScript interface. This standardizes the naming convention to snake_case for consistency across different API representations and marks additional_interfaces as a required field in the JSON schema.
  • New API Structure Documentation: Added a new documentation file (docs/topics/transport-table.md) that provides a comprehensive overview of the API structures and mappings for JSONRPC, gRPC, and REST. This document clarifies method types, URLs, payloads, and responses for various API calls, along with important caveats regarding API design choices.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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

  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.

@pstephengoogle pstephengoogle changed the title Update json names of gRPC objects for proper transcoding chore: Update json names of gRPC objects for proper transcoding Jul 8, 2025
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 updates JSON names for gRPC objects to ensure proper transcoding. The review identified critical issues including inconsistencies in the transport table documentation, duplicate properties in the JSON schema, and missing required properties in both the JSON schema and TypeScript definitions. Addressing these issues is crucial for maintaining data integrity and preventing potential errors.

@holtskinner
Copy link
Member

Overall, it might make sense to use a structure other than a table for this information. Here's an example using tabs.

Screenshot 2025-07-08 at 1 45 32 PM

# API Method Mappings

!!! info "About This Document"
    This document provides the mappings of the 3 different transport types we intend to support in A2A and how these are defined. Though not officially a REST API, the REST-like transport is referred to as the A2A REST API for simplicity.

The base URLs for the transports are:
*   **JSON-RPC:** `{root_url}/` (Method name is in the POST body)
*   **gRPC:** `{root_url}/a2a.A2AService/`
*   **REST:** `{root_url}/`

---

### `tasks/get`
Retrieves a specific task by its ID.

=== "REST"
    *   **Method:** `GET`
    *   **URL:** `/v1/tasks/{id}`
    *   **Query Parameters:**
        ```typescript
        // All parameters are optional
        historyLength?: number
        ```
    *   **Response:**
        ```json
        // Returns a Task object
        ```

=== "gRPC"
    *   **Method:** `GetTask`
    *   **Request:**
        ```proto
        message GetTaskRequest {
          // name = "tasks/{id}"
          string name = 1;
          int32 history_length = 2;
        }
        ```
    *   **Response:**
        ```proto
        // Returns a Task message
        Task
        ```

=== "JSON-RPC"
    *   **Method:** `tasks/get`
    *   **Parameters:**
        ```typescript
        {
          id: string,
          metadata?: { [key: string]: any },
          historyLength?: number
        }
        ```
    *   **Response:**
        ```json
        // Returns a Task object
        ```

---

### `task/cancel`
Cancels a running task.

=== "REST"
    *   **Method:** `POST`
    *   **URL:** `/v1/tasks/{id}:cancel`
    *   **Request Body:** (Empty)
    *   **Response:**
        ```json
        // Returns the updated Task object
        ```

=== "gRPC"
    *   **Method:** `CancelTask`
    *   **Request:**
        ```proto
        message CancelTaskRequest {
          // name = "tasks/{id}"
          string name = 1;
        }
        ```
    *   **Response:**
        ```proto
        // Returns a Task message
        Task
        ```

=== "JSON-RPC"
    *   **Method:** `task/cancel`
    *   **Parameters:**
        ```typescript
        {
          id: string,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response:**
        ```json
        // Returns a Task object
        ```

---

### `message/send`
Sends a message, which may result in a new task or an immediate response.

=== "REST"
    *   **Method:** `POST`
    *   **URL:** `/v1/message:send`
    *   **Request Body:**
        ```typescript
        {
          message: Message,
          configuration?: MessageSendConfiguration,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response:**
        ```typescript
        // Returns one of a message or a task
        {
          message?: Message,
          task?: Task
        }
        ```

=== "gRPC"
    *   **Method:** `SendMessage`
    *   **Request:**
        ```proto
        message SendMessageRequest {
          Message msg = 1;
          SendMessageConfiguration configuration = 2;
        }
        ```
    *   **Response:**
        ```proto
        message SendMessageResponse {
          oneof payload {
            Task task = 1;
            Message msg = 2;
          }
        }
        ```

=== "JSON-RPC"
    *   **Method:** `message/send`
    *   **Parameters:**
        ```typescript
        {
          message: Message,
          configuration?: MessageSendConfiguration,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response:**
        ```json
        // Returns a Message object
        ```

---

### `message/stream`
Sends a message and streams back events, such as status or artifact updates.

=== "REST"
    *   **Method:** `POST`
    *   **URL:** `/v1/message:stream`
    *   **Request Body:**
        ```typescript
        {
          message: Message,
          configuration?: MessageSendConfiguration,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response (Streaming):**
        ```typescript
        // A stream of one of the following objects
        {
          message?: Message,
          task?: Task,
          statusUpdate?: TaskStatusUpdateEvent,
          artifactUpdate?: TaskArtifactUpdateEvent
        }
        ```

=== "gRPC"
    *   **Method:** `SendStreamingMessage`
    *   **Request:**
        ```proto
        message SendMessageRequest {
          Message msg = 1;
          SendMessageConfiguration configuration = 2;
        }
        ```
    *   **Response (Streaming):**
        ```proto
        message StreamResponse {
          oneof payload {
            Task task = 1;
            Message msg = 2;
            TaskStatusUpdateEvent status_update = 3;
            TaskArtifactUpdateEvent artifact_update = 4;
          }
        }
        ```

=== "JSON-RPC"
    *   **Method:** `message/stream`
    *   **Parameters:**
        ```typescript
        {
          message: Message,
          configuration?: MessageSendConfiguration,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response (Streaming):**
        ```json
        // A stream of Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent objects
        ```

---

### `tasks/resubscribe`
Resubscribes to a task's event stream.

=== "REST"
    *   **Method:** `POST`
    *   **URL:** `/v1/tasks/{id}:resubscribe`
    *   **Request Body:** (Empty)
    *   **Response (Streaming):**
        ```typescript
        // A stream of one of the following objects
        {
          message?: Message,
          task?: Task,
          statusUpdate?: TaskStatusUpdateEvent,
          artifactUpdate?: TaskArtifactUpdateEvent
        }
        ```
=== "gRPC"
    *   **Method:** `TaskSubscription`
    *   **Request:**
        ```proto
        message TaskSubscriptionRequest {
          // name = "tasks/{id}"
          string name = 1;
        }
        ```
    *   **Response (Streaming):**
        ```proto
        message StreamResponse {
          oneof payload {
            Task task = 1;
            Message msg = 2;
            TaskStatusUpdateEvent status_update = 3;
            TaskArtifactUpdateEvent artifact_update = 4;
          }
        }
        ```
=== "JSON-RPC"
    *   **Method:** `tasks/resubscribe`
    *   **Parameters:**
        ```typescript
        {
          id: string,
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response (Streaming):**
        ```json
        // A stream of Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent objects
        ```

---

### `tasks/pushNotificationConfig/get`
Retrieves a specific push notification configuration for a task.

=== "REST"
    *   **Method:** `GET`
    *   **URL:** `/v1/tasks/{taskId}/pushNotificationConfigs/{configId}`
    *   **Response:**
        ```json
        // Returns a TaskPushNotificationConfig object
        ```
=== "gRPC"
    *   **Method:** `GetTaskPushNotification`
    *   **Request:**
        ```proto
        message TaskSubscriptionRequest {
          // name = "tasks/{taskId}/pushNotification/{configId}"
          string name = 1;
        }
        ```
    *   **Response:**
        ```proto
        // Returns a TaskPushNotificationConfig message
        TaskPushNotificationConfig
        ```
=== "JSON-RPC"
    *   **Method:** `tasks/pushNotificationConfig/get`
    *   **Parameters:**
        ```typescript
        {
          id: string, // Corresponds to the full resource name
          metadata?: { [key: string]: any }
        }
        ```
    *   **Response:**
        ```json
        // Returns a TaskPushNotificationConfig object
        ```

---

### `tasks/pushNotificationConfig/set`
Creates or updates a push notification configuration for a task.

=== "REST"
    *   **Method:** `POST`
    *   **URL:** `/v1/tasks/{id}/pushNotificationConfigs`
    *   **Request Body:**
        ```typescript
        {
          config: TaskPushNotificationConfig
        }
        ```
    *   **Response:**
        ```json
        // Returns the created/updated TaskPushNotificationConfig object
        ```
=== "gRPC"
    *   **Method:** `CreateTaskPushNotification`
    *   **Request:**
        ```proto
        message SetTaskPushNotificationRequest {
          TaskPushNotificationConfig config = 1;
        }
        ```
    *   **Response:**
        ```proto
        // Returns the created/updated TaskPushNotificationConfig message
        TaskPushNotificationConfig
        ```
=== "JSON-RPC"
    *   **Method:** `tasks/pushNotificationConfig/set`
    *   **Parameters:**
        ```typescript
        // A TaskPushNotificationConfig object
        ```
    *   **Response:**
        ```json
        // Returns the created/updated TaskPushNotificationConfig object
        ```

---

### `card/get`
Retrieves the agent's card.

=== "REST"
    *   **Method:** `GET`
    *   **URL:** `/v1/card`
    *   **Request Body:** None
    *   **Response:**
        ```json
        // Returns an AgentCard object
        ```
=== "gRPC"
    *   **Method:** `GetAgentCard`
    *   **Request:** None (Empty)
    *   **Response:**
        ```proto
        // Returns an AgentCard message
        AgentCard
        ```
=== "JSON-RPC"
    *   This method is not currently defined for the JSON-RPC transport.

---

### `tasks/pushNotificationConfig/list`
Lists all push notification configurations for a given task.

=== "REST"
    *   **Method:** `GET`
    *   **URL:** `/v1/tasks/{id}/pushNotificationConfigs`
    *   **Response:**
        ```json
        // Returns an array of TaskPushNotificationConfig objects
        [ TaskPushNotificationConfig, ... ]
        ```
=== "gRPC"
    *   **Method:** `ListTaskPushNotification`
    *   **Request:**
        ```proto
        message ListTaskPushNotificationRequest {
          // parent = "tasks/{id}"
          string parent = 1;
        }
        ```
    *   **Response:**
        ```proto
        // Returns a repeated field of TaskPushNotificationConfig messages
        repeated TaskPushNotificationConfig
        ```
=== "JSON-RPC"
    *   Not applicable.

---

### `tasks/list`
Lists all tasks.

=== "REST"
    *   **Method:** `GET`
    *   **URL:** `/v1/tasks`
    *   **Request Body:** None
    *   **Response:**
        ```json
        // Returns an array of Task objects
        [ Task, ... ]
        ```
=== "gRPC"
    *   **Method:** `ListTask`
    *   **Request:** None (Empty)
    *   **Response:**
        ```proto
        // Returns a repeated field of Task messages
        repeated Task
        ```
=== "JSON-RPC"
    *   Not applicable.

@pstephengoogle
Copy link
Contributor Author

I don't disagree with a different format being easier, however I don't have bandwidth to make this change, perhaps as a follow on PR from someone with the time?

@holtskinner holtskinner changed the title chore: Update json names of gRPC objects for proper transcoding fix: Update json names of gRPC objects for proper transcoding Jul 8, 2025
@holtskinner holtskinner enabled auto-merge (squash) July 8, 2025 20:30
@holtskinner holtskinner disabled auto-merge July 8, 2025 20:30
@holtskinner holtskinner merged commit 6ba72f0 into main Jul 8, 2025
2 of 3 checks passed
@holtskinner holtskinner deleted the events branch July 8, 2025 20:30
holtskinner added a commit that referenced this pull request Jul 17, 2025
🤖 I have created a release *beep* *boop*
---


## [0.2.6](v0.2.5...v0.2.6)
(2025-07-17)

### Bug Fixes

* Type fix and doc clarification
([#877](#877))
([6f1d17b](6f1d17b))
* Update json names of gRPC objects for proper transcoding
([#847](#847))
([6ba72f0](6ba72f0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
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.

4 participants