Skip to content

Conversation

@t-miyak
Copy link

@t-miyak t-miyak commented Nov 1, 2025

Summary

Implements support for propagating Pydantic Field metadata (descriptions and required fields) to function declaration schemas, enabling LLMs to receive accurate parameter information when using Pydantic models as function tool arguments.

@gemini-code-assist
Copy link

Summary of Changes

Hello @t-miyak, 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 function declaration generation process by integrating Pydantic Field metadata. Specifically, it ensures that field descriptions and their required status are accurately reflected in the generated schemas. This improvement is crucial for Large Language Models (LLMs) to receive precise and complete parameter information when utilizing Pydantic models as function tool arguments, leading to more robust and intelligent tool interactions.

Highlights

  • Pydantic Field Description Propagation: The system now correctly extracts and applies descriptions from Pydantic Field metadata to the generated function declaration schemas, providing richer context for parameters.
  • Pydantic Field Required Status Reflection: The required status of Pydantic fields, determined by Field metadata, is now accurately reflected in the function declaration schemas, ensuring LLMs understand which parameters are mandatory.
  • Enhanced Testing for Pydantic Metadata: A new, comprehensive test case has been added to validate the correct propagation of description and required attributes for nested Pydantic models, including those using Optional types and Field annotations.
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
Copy link
Collaborator

adk-bot commented Nov 1, 2025

Response from ADK Triaging Agent

Hello @t-miyak, thank you for creating this PR!

To help reviewers evaluate your contribution, could you please address the following points from our contribution guidelines:

  • Associated Issue: For new features, please create an issue that describes the feature and associate it with this PR.
  • Testing Plan: Please add a testing plan section to your PR description to detail how you've tested these changes.

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

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Nov 1, 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 adds a valuable feature to reflect Pydantic Field metadata, such as descriptions and required status, in the generated function declaration schemas. The implementation correctly extracts this information, and the new unit test is comprehensive, covering various scenarios with nested models and different field types. I have one suggestion to slightly refactor the code for improved efficiency and clarity. Overall, the changes are well-implemented and tested.

Comment on lines 307 to 311
schema.required = [
field_name
for field_name, field_info in param.annotation.model_fields.items()
if field_info.is_required()
]

Choose a reason for hiding this comment

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

medium

For better performance and code clarity, you can determine the required fields within the main loop that processes each field (lines 291-305), rather than iterating over model_fields a second time here. You could initialize schema.required = [] before the loop, and then append field_name to it inside the loop when field_info.is_required() is true.

Copy link
Author

Choose a reason for hiding this comment

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

addressed by 7709595...ad8a0e4

@ryanaiagent ryanaiagent self-assigned this Nov 3, 2025
@ryanaiagent
Copy link
Collaborator

Hi @t-miyak , Thank you for your contribution!
To complete the review, could you also add a brief manual E2E test plan to confirm the LLM correctly interprets and uses this new metadata in a live scenario?

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.

3 participants