Skip to content

Conversation

@yeesian
Copy link

@yeesian yeesian commented Jan 9, 2026

Description

Fixes #13734

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

@yeesian yeesian requested review from a team as code owners January 9, 2026 20:51
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 9, 2026
@snippet-bot
Copy link

snippet-bot bot commented Jan 9, 2026

Here is the summary of possible violations 😱

Details

There are 5 possible violations for not having product prefix.

The end of the violation section. All the stuff below is FYI purposes only.


Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yeesian, 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 comprehensive new Python code sample designed to guide users through the process of building and deploying agents using the Vertex AI Agent Engine and Agent Development Kit (ADK). The sample provides an end-to-end demonstration, covering the definition of a custom tool for an agent, agent initialization, local and remote testing, and deployment to Vertex AI, ultimately addressing issue #13734. It aims to simplify the understanding and implementation of custom agent functionalities within the Google Cloud ecosystem.

Highlights

  • New Code Sample Added: A new Python file, generative_ai/reasoning_engine/quickstart_adk_example.py, has been added to demonstrate the use of Vertex AI Agent Engine with the Agent Development Kit (ADK).
  • Custom Tool Definition: The sample includes a get_exchange_rate function, showcasing how to define a custom tool that an Agent Engine can utilize to fetch real-world data, specifically currency exchange rates from an external API.
  • Agent Initialization and Configuration: It illustrates the process of initializing an Agent using the gemini-2.0-flash model and integrating the custom get_exchange_rate tool.
  • Local and Remote Agent Testing: The code provides examples for both local testing of the agent using app.async_stream_query and remote testing after deployment to Vertex AI Agent Engines.
  • Agent Deployment to Vertex AI: The sample demonstrates how to deploy the configured agent to Vertex AI Agent Engines, including specifying necessary requirements and a staging_bucket.
  • Resource Cleanup: The example concludes with the deletion of the remotely deployed agent, ensuring proper resource management.
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 adds a new quickstart example for the Agent Engine using the ADK. The new code contains several critical issues that will prevent it from running, including a SyntaxError due to using async for in a synchronous function, an IndentationError, and a NameError from an incorrect type hint. I've also pointed out some areas for improvement regarding error handling, type hints, and code style consistency. Addressing these issues will make the sample code correct and robust.

return response.json()
# [END agentengine_quickstart_adk_tool]

def quickstart_adk_example(staging_bucket: str) -> reasoning_engines.ReasoningEngine:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The function signature has two critical issues that will prevent the code from running:

  1. It uses async for loops (on lines 41 and 60), which is only valid inside an async function. The function must be defined with async def.
  2. The return type hint -> reasoning_engines.ReasoningEngine is incorrect. The name reasoning_engines is not defined, and the function actually returns events, which is a list. This will cause a NameError.
Suggested change
def quickstart_adk_example(staging_bucket: str) -> reasoning_engines.ReasoningEngine:
async def quickstart_adk_example(staging_bucket: str) -> list:

Comment on lines +65 to +66
# [END agentengine_quickstart_adk_testremotely]
events.append(event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This block of code contains an IndentationError on line 66 due to an unexpected indent. It appears the intention is to append each event to the events list within the loop. To fix this, events.append(event) should be inside the loop, and the [END ...] region tag should be placed after it.

Suggested change
# [END agentengine_quickstart_adk_testremotely]
events.append(event)
events.append(event)
# [END agentengine_quickstart_adk_testremotely]

Comment on lines +10 to +14
def get_exchange_rate(
currency_from: str = "USD",
currency_to: str = "EUR",
currency_date: str = "latest",
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function is missing a return type hint. Based on the response.json() call, it should return a dict. Adding type hints improves code clarity and allows static analysis tools to catch potential bugs. The project configuration (noxfile_config.py) also specifies enforce_type_hints: True.

Suggested change
def get_exchange_rate(
currency_from: str = "USD",
currency_to: str = "EUR",
currency_date: str = "latest",
):
def get_exchange_rate(
currency_from: str = "USD",
currency_to: str = "EUR",
currency_date: str = "latest",
) -> dict:

f"https://api.frankfurter.app/{currency_date}",
params={"from": currency_from, "to": currency_to},
)
return response.json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The HTTP request to the Frankfurter API does not handle potential errors, such as network issues or non-200 status codes. This could lead to unexpected behavior or crashes if the API is unavailable or returns an error. It's good practice to check for a successful response by adding response.raise_for_status() before this line.


agent = Agent(
model="gemini-2.0-flash",
name='currency_exchange_agent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The string literal for the agent name uses single quotes, while other strings in this file (e.g., for the model name) use double quotes. To maintain a consistent coding style, it's recommended to use double quotes for all strings, following PEP 8 recommendations for consistency.

Suggested change
name='currency_exchange_agent',
name="currency_exchange_agent",

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

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add doc samples for Agent Engine

1 participant