Skip to content

Conversation

@kamalaboulhosn
Copy link
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

N/A

Testing Plan

Added unit tests for all newly created classes, added a sample with an agent that depends on the new tool, tested that sample manually.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
================================================================================= 27 passed, 58 warnings in 5.62s ==================================================================================

The warnings are because the tools have been marked experimental.

Manual End-to-End (E2E) Tests:

A sample agent has been provided in the PR. It can be run with adk web. One can run commands like the following in it to see that it works:

Publish the message "HI2" to the topic projects/<PROJECT>/topics/<TOPIC>
Pull messages from the subscription projects/<PROJECT>/subscriptions/<SUBSCRIPTION>
Ack the messages

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

N/A

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kamalaboulhosn, 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 integrates a new, handwritten toolset for Google Cloud Pub/Sub into the ADK framework. The primary goal is to provide more tailored and user-friendly tools for interacting with Pub/Sub topics and subscriptions, specifically addressing limitations found in auto-generated API tools, such as message encoding and subscription management. The changes include the core tool implementations, a dedicated configuration system, credential handling, and a fully functional sample agent with detailed usage instructions, making it easier for developers to leverage Pub/Sub within their ADK applications.

Highlights

  • New Pub/Sub Toolset: Introduced a handwritten toolset for Google Cloud Pub/Sub, offering publish_message, pull_messages, and acknowledge_messages functionalities.
  • Enhanced Functionality: The new tools are custom-built to provide better handling of base64 encoding for messages and a richer subscribe-side API compared to auto-generated tools.
  • Sample Agent & Documentation: A new sample agent (contributing/samples/pubsub/agent.py) and a comprehensive README.md are included to demonstrate and guide the usage of these Pub/Sub tools with various authentication methods.
  • Dependency Update: The google-cloud-pubsub library has been added as a project dependency in pyproject.toml.
  • Extensive Testing: New unit tests cover the PubSubClient, PubSubToolConfig, PubSubCredentialsConfig, PubSubMessageTool, and PubSubToolset classes, ensuring functionality and proper configuration.
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.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Dec 8, 2025
@kamalaboulhosn
Copy link
Contributor Author

Note that the failing check-file-contents check is because this change imports from google.api_core.gapic_v1.client_info, which it takes to mean it is importing from the cli package, which it is not.

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 a new handwritten toolset for Google Cloud Pub/Sub, complete with tools for publishing, pulling, and acknowledging messages. The changes include the core tool logic, configuration models, a comprehensive sample agent with a README, and a full suite of unit tests.

The implementation is well-structured, but I've identified a critical thread-safety issue in the client caching mechanism that could lead to race conditions. I've provided suggestions to add locking to resolve this. Additionally, I've pointed out a potential typo in the sample agent's model name and a small improvement for timestamp formatting in the tool's output.

Overall, this is a great addition, and with these fixes, it will be a robust and valuable tool.

kamalaboulhosn and others added 4 commits December 8, 2025 07:53
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@kamalaboulhosn kamalaboulhosn changed the title Add a handwritten tool for Cloud Pub/Sub feat: Add a handwritten tool for Cloud Pub/Sub Dec 8, 2025
@xuanyang15 xuanyang15 self-assigned this Dec 8, 2025
@ryanaiagent ryanaiagent added the request clarification [Status] The maintainer need clarification or more information from the author label Dec 11, 2025
@ryanaiagent
Copy link
Collaborator

Hi @kamalaboulhosn , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Can you please fix the failing unit tests.

@kamalaboulhosn
Copy link
Contributor Author

@ryanaiagent Looks like the test failures were unrelated to my change and fixed by 99f893a. I did an Update branch to pull that in, which triggered a re-run on the tests, and they are now passing. Thanks!

@ryanaiagent ryanaiagent removed the request clarification [Status] The maintainer need clarification or more information from the author label Dec 11, 2025
copybara-service bot pushed a commit that referenced this pull request Dec 16, 2025
Merge #3865

COPYBARA_INTEGRATE_REVIEW=#3865 from kamalaboulhosn:main 37a38a4
PiperOrigin-RevId: 845345128
@adk-bot
Copy link
Collaborator

adk-bot commented Dec 16, 2025

Thank you @kamalaboulhosn for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit b6f6dcb.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot closed this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add better support for Cloud Pub/Sub

4 participants