Skip to content

Conversation

jutaz
Copy link

@jutaz jutaz commented Sep 5, 2025

Description

This pull request resolves a critical API compatibility issue with the Google Gemini API, which would cause tool calls to fail with a 400 Bad Request error. The fix has been architected into a scalable, strategy-based pattern to handle model-specific tool schema requirements, ensuring future extensibility.

The core of the solution is a new configuration-driven system that allows the server to dynamically select the correct schema at runtime. When the server is started with --target-model gemini, it provides a simplified, compatible schema. For all other models, it provides a richer, more expressive schema. This is all managed by a new, centralized "schema strategy" system.

This new feature is fully documented for both end-users (new configuration flags) and future developers (a guide to the new architecture).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • I have tested these changes locally
  • My code follows the project's style
  • I have updated the documentation if needed

This commit introduces a new compatibility mode for Google Gemini. It allows the application to adapt its behavior based
on the specific model being used.

This includes the following changes:

- Added a new `ModelTarget` enum for Gemini. - Added a new `AppConfig` interface for the server's configuration. - Added
a new `config.ts` file to manage the server's runtime config. - Added a utility function to check if the Gemini
compatibility mode is active. - Modified the `ask-gemini.tool.ts` file to use the new config. - Added startup
initialization for the app config in `index.ts`.
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.

Summary of Changes

Hello @jutaz, 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 robust solution to address API compatibility challenges with the Google Gemini API, specifically concerning tool call failures. It establishes a flexible, configuration-driven system that intelligently adapts tool schemas based on the target large language model, ensuring seamless integration and preventing common API errors. The changes are designed to be extensible, allowing for future support of diverse model requirements, and are thoroughly documented for both end-users and developers.

Highlights

  • Gemini API Compatibility Fix: Resolved a critical API compatibility issue with the Google Gemini API that caused tool calls to fail with a 400 Bad Request error. This ensures reliable tool execution when interacting with Gemini models.
  • Strategy-Based Schema Handling: Implemented a scalable, strategy-based pattern to handle model-specific tool schema requirements. This allows the server to dynamically select the correct schema at runtime, ensuring future extensibility and compatibility with various LLMs.
  • Configuration-Driven System: Introduced a new configuration-driven system that allows users to specify a target model via a --target-model command-line flag or MCP_TARGET_MODEL environment variable. When --target-model gemini is used, a simplified, compatible schema is provided, while other models receive a richer, more expressive schema.
  • Enhanced Documentation: Updated user-facing documentation (README.md, docs/installation.md) to guide users on enabling Gemini compatibility mode. A new developer guide (docs/concepts/schema-compatibility.md) has been added to explain the new architecture and how to add compatible parameters.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 introduces a well-architected solution for handling model-specific tool schema requirements, specifically for Gemini compatibility. The use of a strategy pattern is a great choice for extensibility. The new configuration system via command-line flags and environment variables is robust and clearly documented for both users and developers. The code changes are clean and effective. I have a few suggestions to further improve maintainability and consistency, mainly around typing and the use of helper functions.

- Corrected type assertions for `args` to match the schema. - Ensured `prompt` is correctly passed to
`executeGeminiCLI`. - Updated `selectChunkIndexSchema` to use `isGeminiTarget`.
@jutaz
Copy link
Author

jutaz commented Sep 10, 2025

bump @jamubc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant