Skip to content

feat: Add agent-to-agent communication testing (#625)#654

Open
kabir wants to merge 7 commits intoa2aproject:mainfrom
kabir:agent2agenttest
Open

feat: Add agent-to-agent communication testing (#625)#654
kabir wants to merge 7 commits intoa2aproject:mainfrom
kabir:agent2agenttest

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Feb 13, 2026

Implements server-side agent-to-agent communication where an AgentExecutor can use a client to connect back to the same server, enabling agents to delegate work to other agents.

Fixes #625 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kabir, 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 introduces a significant new capability: server-side agent-to-agent communication. This feature allows an agent, specifically an AgentExecutor, to act as a client and delegate work to other agents running on the same server. This enables more complex agent orchestration patterns where agents can request services from their peers. The changes include updates to various transport handlers to record the active protocol, a new ServerCallContext key for transport identification, and robust testing infrastructure to ensure the delegation works across different communication protocols.

Highlights

  • Agent-to-Agent Communication: Introduced server-side agent-to-agent communication, allowing an AgentExecutor to delegate tasks to other agents on the same server using a client.
  • Transport Protocol Identification: Added a TRANSPORT_KEY to ServerCallContext to store and retrieve the active transport protocol (JSONRPC, HTTP_JSON, GRPC) for incoming requests, enabling transport-aware client creation for delegation.
  • New Test Infrastructure: Implemented a comprehensive test case (testAgentToAgentCommunication) to validate the agent-to-agent delegation mechanism, including a new AgentToAgentClientFactory to dynamically create clients for different transport types.
  • Dependency Update: Added a new test dependency for a2a-java-sdk-client-transport-jsonrpc to support agent-to-agent communication tests.
Changelog
  • reference/jsonrpc/pom.xml
    • Added a2a-java-sdk-client-transport-jsonrpc as a test dependency.
  • reference/jsonrpc/src/main/java/io/a2a/server/apps/quarkus/A2AServerRoutes.java
    • Imported ServerCallContext.TRANSPORT_KEY and TransportProtocol.
    • Set the TRANSPORT_KEY in the ServerCallContext state to TransportProtocol.JSONRPC.
  • reference/rest/src/main/java/io/a2a/server/rest/quarkus/A2AServerRoutes.java
    • Imported ServerCallContext.TRANSPORT_KEY and TransportProtocol.
    • Set the TRANSPORT_KEY in the ServerCallContext state to TransportProtocol.HTTP_JSON.
  • server-common/src/main/java/io/a2a/server/ServerCallContext.java
    • Added a new public static final string TRANSPORT_KEY to identify the transport protocol in the state map.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java
    • Added imports for UUID and Collectors.
    • Removed a System.out.println debugging statement.
    • Implemented testAgentToAgentCommunication to verify agent-to-agent delegation and local handling.
    • Added a private helper method extractTextFromTask to process task artifacts.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AgentExecutorProducer.java
    • Added imports for client-side components, TransportProtocol, and ServerCallContext.TRANSPORT_KEY.
    • Injected AgentCard to enable client creation.
    • Modified the execute method to handle agent-to-agent test messages, distinguishing between delegated and local tasks.
    • Introduced handleAgentToAgentTest, handleDelegation, and handleLocally private methods to manage the delegation logic.
    • Added getServerUrl helper method to determine the correct server URL based on the transport protocol for testing.
  • tests/server-common/src/test/java/io/a2a/server/apps/common/AgentToAgentClientFactory.java
    • Added a new file AgentToAgentClientFactory to create A2A clients for different transport protocols dynamically.
    • Defined ClientTransportEnhancer interface and its implementations (GrpcClientEnhancer, JsonRpcClientEnhancer, RestClientEnhancer) to configure transport-specific client builders.
  • transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcHandler.java
    • Imported ServerCallContext.TRANSPORT_KEY and TransportProtocol.
    • Set the TRANSPORT_KEY in the ServerCallContext state to TransportProtocol.GRPC.
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.

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.

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 effectively implements agent-to-agent communication by passing the transport protocol through the ServerCallContext. The new AgentExecutor logic correctly uses this context to create a client and delegate tasks. The addition of a comprehensive test case in AbstractA2AServerTest is great for verifying this new feature. My review includes a few suggestions to improve code maintainability by reducing duplication and clarifying documentation.

@kabir
Copy link
Collaborator Author

kabir commented Feb 13, 2026

/gemini review

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 introduces agent-to-agent communication support by passing the transport protocol via the ServerCallContext. This enables an AgentExecutor to instantiate a client with a matching transport to delegate tasks to other agents on the same server. The implementation correctly spans the JSON-RPC, REST, and gRPC transport layers, and is accompanied by new tests verifying both delegation and local handling scenarios. My feedback focuses on enhancing code maintainability by addressing duplication in the test suite and leveraging modern Java features for more concise and robust code.

@kabir
Copy link
Collaborator Author

kabir commented Feb 16, 2026

/gemini review

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 introduces agent-to-agent communication, a significant feature enabling agents to delegate tasks to one another. The implementation correctly passes transport information via the ServerCallContext and includes comprehensive tests for both delegation and local handling scenarios. My review provides suggestions to improve code maintainability by refactoring duplicated logic in tests and to modernize the code by adopting try-with-resources and switch expressions for better readability and robustness.

@kabir
Copy link
Collaborator Author

kabir commented Feb 16, 2026

/gemini review

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 introduces support for agent-to-agent communication by passing the transport protocol through the ServerCallContext. The changes are well-implemented across the different transport layers (JSON-RPC, REST, gRPC). The new tests in AbstractA2AServerTest provide good coverage for the delegation and local handling scenarios. The suggestion regarding code duplication in the test utilities is valid and aligns with general good practices for maintainability, even in test code.

@kabir
Copy link
Collaborator Author

kabir commented Feb 16, 2026

/gemini review

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 introduces agent-to-agent communication, a significant feature enabling agents to delegate tasks to one another. The implementation correctly passes transport information through the call context and includes a good set of tests covering delegation and local handling scenarios. My review has identified a high-severity issue in the test client factory that causes it to connect to an incorrect URL, which could lead to test failures in certain environments. I've also included a few medium-severity suggestions to improve code quality and maintainability by addressing code duplication and removing an unused parameter in the test suite.

@kabir
Copy link
Collaborator Author

kabir commented Feb 16, 2026

/gemini review

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 successfully implements server-side agent-to-agent communication. The approach of passing the transport protocol via the ServerCallContext is clean and allows the AgentExecutor to create a client with the matching transport for delegation. The changes are consistently applied across the JSON-RPC, REST, and gRPC transport layers. The addition of new integration tests in AbstractA2AServerTest and the helper AgentToAgentClientFactory provides good coverage for the new delegation and local handling logic. My main feedback is to improve the exception handling within the test AgentExecutorProducer to ensure that, while broad catches are permissible in test classes, original error causes are preserved for easier debugging. Overall, this is a solid implementation of a key feature.

Implements server-side agent-to-agent communication where an AgentExecutor
can use a client to connect back to the same server, enabling agents to
delegate work to other agents.
@kabir kabir changed the title feat: Add agent-to-agent communication support (#625) feat: Add agent-to-agent communication testing (#625) Feb 17, 2026
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.

Add tests using client from an AgentExecutor

2 participants