Skip to content

Conversation

@secprog
Copy link

@secprog secprog commented Oct 21, 2025

Added optional services for session, artifact, memory, and credential management to the agent_to_a2a function.
Fixes #3104
Added tests.

Added optional services for session, artifact, memory, and credential management to the agent_to_a2a function.
@google-cla
Copy link

google-cla bot commented Oct 21, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link

Summary of Changes

Hello @secprog, 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 enhances the agent_to_a2a utility function by introducing optional parameters for various core services, including session, artifact, memory, and credential management. This change allows for greater flexibility and customization, enabling developers to inject their own service implementations rather than being limited to the default in-memory versions. The modification improves the modularity and testability of agents converted to A2A Starlette applications, addressing issue #3104.

Highlights

  • Service Extensibility: The agent_to_a2a function now supports optional dependency injection for session, artifact, memory, and credential management services, allowing for custom implementations.
  • Default In-Memory Services: By default, the function continues to use in-memory implementations for these services, ensuring backward compatibility and ease of use.
  • Improved Documentation: The to_a2a function's docstring has been updated to clearly describe the newly added service parameters and their purpose.
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

@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 enhances the agent_to_a2a function by allowing optional services for session, artifact, memory, and credential management to be passed as arguments. This is a great improvement for flexibility and testability, moving from hardcoded in-memory services to injectable dependencies. My review focuses on improving code style and consistency by sorting the new imports and parameters alphabetically.

A significant concern is the lack of updated tests. The new functionality of passing custom services is not covered by any tests. Existing tests only verify the default behavior with InMemory services. It's crucial to add a new test case that passes mock services to to_a2a and asserts that the Runner is initialized with these mocks. This will ensure the dependency injection works as expected and prevent future regressions.

Overall, the changes are well-implemented and improve the codebase, but require the addition of tests to be complete.

secprog and others added 6 commits October 21, 2025 17:37
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Oct 22, 2025
@adk-bot
Copy link
Collaborator

adk-bot commented Oct 22, 2025

Response from ADK Triaging Agent

Hello @secprog, thank you for creating this PR!

Could you please include a testing plan section in your PR to talk about how you will test this new feature? This will save time for PR review.

This information will help reviewers to review your PR more efficiently. Thanks!

@adk-bot adk-bot requested a review from DeanChensj October 22, 2025 17:24
@secprog
Copy link
Author

secprog commented Oct 22, 2025

Response from ADK Triaging Agent

Hello @secprog, thank you for creating this PR!

Could you please include a testing plan section in your PR to talk about how you will test this new feature? This will save time for PR review.

This information will help reviewers to review your PR more efficiently. Thanks!

Added tests, for the changed functionality.

@secprog
Copy link
Author

secprog commented Oct 22, 2025

/gemini review

Copy link

@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 enhances the agent_to_a2a function by allowing optional services for session, artifact, memory, and credential management, which is a great improvement for flexibility. The addition of comprehensive tests is also much appreciated.

My review focuses on a few key areas:

  • There's a critical issue with the use of mutable default arguments for the new service parameters, which could lead to shared state and unexpected behavior across different agent setups. I've provided suggestions to fix this.
  • I've also suggested some minor improvements to the docstring for consistency and correctness.
  • In the tests, I've pointed out opportunities to reduce code duplication by using fixtures, and to improve the effectiveness of one of the validation tests.

Overall, this is a solid contribution. Addressing these points will make the implementation more robust and maintainable.

secprog and others added 6 commits October 22, 2025 21:05
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rameter validation

Added a new fixture `mock_a2a_components` to streamline the mocking of A2A components in tests. Updated existing tests to utilize this fixture, improving readability and maintainability. Enhanced service parameter validation tests to ensure correct handling of custom services.
@secprog
Copy link
Author

secprog commented Oct 22, 2025

/gemini review

Copy link

@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 enhances the agent_to_a2a function by allowing optional services for session, artifact, memory, and credential management. This is a great improvement for configurability. The implementation is correct, and the new tests provide good coverage for the new functionality. I've made a couple of suggestions to improve code style and test suite maintainability.

secprog and others added 2 commits October 22, 2025 21:15
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…in to_a2a function

Updated the docstring for the session_service parameter to enhance readability by breaking it into multiple lines. This change aims to maintain consistency in documentation style across the codebase.
@secprog
Copy link
Author

secprog commented Oct 22, 2025

/gemini review

Copy link

@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 enhances the agent_to_a2a function by introducing optional service parameters for artifact, credential, memory, and session management. This change increases the flexibility of the function by allowing users to provide their own service implementations instead of relying on the default in-memory ones. The implementation is straightforward and correct, using the or operator to fall back to default services. The pull request also includes a good set of new tests that cover various scenarios, including using custom services, default services, and a mix of both. My main suggestion is to refactor the existing tests to use the new mock_a2a_components fixture to improve code consistency and maintainability within the test file.

Refactored unit tests in `test_agent_to_a2a.py` to use the new `mock_a2a_components` fixture for improved readability and maintainability. This change consolidates mock setup, reducing redundancy across tests while ensuring consistent behavior in assertions.
@secprog
Copy link
Author

secprog commented Oct 22, 2025

/gemini review

Copy link

@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 enhances the agent_to_a2a function by allowing optional services for session, artifact, memory, and credential management, with sensible fallbacks to in-memory implementations. This is a great enhancement for flexibility. The implementation is clean and the accompanying tests are thorough. The refactoring of the test suite to use a pytest fixture is a significant improvement, making the tests much more readable and maintainable. I have a couple of minor suggestions to further improve code style and consistency.

secprog and others added 2 commits October 22, 2025 21:28
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@secprog
Copy link
Author

secprog commented Oct 22, 2025

/gemini review

@ryanaiagent ryanaiagent self-assigned this Oct 22, 2025
Copy link

@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 enhances the agent_to_a2a function by allowing optional service implementations, which increases flexibility. The implementation is clean and effectively uses the or pattern for providing default in-memory services. The accompanying tests are thorough and cover various scenarios, including custom services, default fallbacks, and mixed configurations. Furthermore, the refactoring of existing tests to use a pytest fixture is an excellent improvement that significantly reduces code duplication and enhances test readability and maintainability. Overall, this is a high-quality contribution.

@ryanaiagent
Copy link
Collaborator

Hi @secprog, Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The to_a2a() function should allow for configuration of artifact_service, session_service, memory_service and credential_service

4 participants