Skip to content

fix(py): fix model config consistencies for gemini#4463

Merged
MengqinShen merged 3 commits intomainfrom
elisa/fix/model-config-consistencies-gemini
Feb 6, 2026
Merged

fix(py): fix model config consistencies for gemini#4463
MengqinShen merged 3 commits intomainfrom
elisa/fix/model-config-consistencies-gemini

Conversation

@MengqinShen
Copy link
Contributor

@MengqinShen MengqinShen commented Feb 6, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MengqinShen, 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 focuses on improving the robustness and feature set of the Python Genkit runtime and its Google GenAI plugin. It refines asynchronous operations within the core runtime for better stability and simplifies server lifecycle management. Concurrently, it significantly enhances the Gemini model's capabilities by enabling asynchronous data conversions, supporting remote image ingestion, and providing richer output parsing for model responses, aligning the plugin more closely with the full range of Gemini API features.

Highlights

  • Python Genkit Runtime Refinements: The core asynchronous runtime (_base_async.py) has been streamlined by removing explicit SIGTERM handling and simplifying task group management, relying more on anyio's default cancellation mechanisms. The handling of user coroutine results after task group completion has also been adjusted for clarity.
  • Enhanced Gemini Model Integration: The Google GenAI plugin's Gemini model integration (gemini.py) now provides more comprehensive response parsing, including finish_reason, multiple candidates, and usage statistics. Configuration handling has been improved, and the conversion of Genkit parts to Gemini parts and configuration methods are now asynchronous.
  • Asynchronous Image Handling for Gemini: The PartConverter utility (utils.py) has been updated to asynchronously download images from HTTP URLs and convert them into inline data for Gemini models. This improves flexibility when dealing with remote image assets.
  • Simplified Sample Application Lifecycle: The main.py sample application now uses a continuous asyncio.sleep loop to keep the Dev UI alive, replacing the previous asyncio.Event().wait() mechanism.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • py/packages/genkit/src/genkit/ai/_base_async.py
    • Removed signal import and explicit SIGTERM handling logic.
    • Simplified dev_runner's task group management and user coroutine result handling.
    • Updated type hints for user_result and removed name arguments from tg.start_soon calls.
  • py/plugins/google-genai/src/genkit/plugins/google_genai/models/gemini.py
    • Imported Candidate and FinishReason for richer response typing.
    • Converted _genkit_to_googleai_cfg and _contents_from_response methods to be asynchronous.
    • Removed redundant tool validation for image models.
    • Implemented detailed parsing of Gemini API responses to extract finish_reason, candidates, and usage statistics into Genkit's GenerateResponse format.
    • Refactored system message handling within _genkit_to_googleai_cfg for better consistency.
  • py/plugins/google-genai/src/genkit/plugins/google_genai/models/utils.py
    • Added httpx and get_cached_client imports for HTTP requests.
    • Made PartConverter.to_gemini asynchronous to support network operations.
    • Introduced logic to PartConverter.to_gemini to download HTTP image URLs and convert them to inline data, with a fallback to file_data.
    • Modified PartConverter.from_gemini to handle cases where function_call.args might be None.
    • Added a new async helper method _download_image for fetching image data from URLs.
  • py/samples/google-genai-hello/src/main.py
    • Updated the main function to use an asyncio.sleep(3600) loop for keeping the process alive, replacing asyncio.Event().wait().
Activity
  • The pull request title indicates a focus on fixing model configuration inconsistencies for Gemini.
  • The PR description includes placeholder items for linking to issues, providing samples, and a checklist, suggesting these details might be elaborated elsewhere or are standard template items.
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 introduces several refactorings and fixes for model configuration consistency, particularly for Gemini models. The changes include making several methods asynchronous to support downloading media from URLs, improving the GenerateResponse with more details like candidates and usage, and simplifying the development server runner.

My review has identified a critical issue in the development server logic that causes it to hang instead of returning results from short-lived coroutines. I've also pointed out a couple of medium-severity issues related to silent error handling and unreachable code. Overall, the changes are a good step towards improving consistency, but the critical issue in _base_async.py needs to be addressed.

@github-actions github-actions bot added the config label Feb 6, 2026
@MengqinShen MengqinShen marked this pull request as ready for review February 6, 2026 07:14
@MengqinShen MengqinShen requested a review from yesudeep February 6, 2026 07:14
@MengqinShen MengqinShen enabled auto-merge (squash) February 6, 2026 07:20
@MengqinShen MengqinShen merged commit 8a012b8 into main Feb 6, 2026
17 checks passed
@MengqinShen MengqinShen deleted the elisa/fix/model-config-consistencies-gemini branch February 6, 2026 07:27
@yesudeep yesudeep mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants