Skip to content

Comments

chore(genkit-tools): update model and middleware types#4785

Open
MichaelDoyle wants to merge 1 commit intomainfrom
update-tools
Open

chore(genkit-tools): update model and middleware types#4785
MichaelDoyle wants to merge 1 commit intomainfrom
update-tools

Conversation

@MichaelDoyle
Copy link
Member

@MichaelDoyle MichaelDoyle commented Feb 20, 2026

  • I'm "pulling forward" the middleware schema, so to speak
  • Updated a couple small things missing in js/ai/src/model.ts and js/ai/src/parts.ts as well.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MichaelDoyle, 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 refining and expanding the type definitions within the genkit-tools project, particularly for models and middleware. The changes aim to provide more robust and descriptive schemas for various components, enhance configuration options for generation requests, and ensure the JSON schema accurately reflects these updated types. This improves clarity, maintainability, and consistency across the codebase.

Highlights

  • Middleware Type Definition: Introduced a new MiddlewareDescSchema and MiddlewareDesc type to define the structure for registered middleware, including its name, description, configuration schema, and metadata.
  • Model and Part Type Refinements: Re-organized and refined PartSchema definitions across model.ts and parts.ts. The comprehensive PartSchema (union of all part types) is now defined in model.ts, while parts.ts provides a simplified PartSchema for text and media, along with specific type exports.
  • Enhanced Generation Configuration: Updated GenerationCommonConfigSchema with more detailed descriptions for existing properties, added an apiKey field, and changed its behavior to allow additional properties (passthrough).
  • New Model Reference Schema: Added ModelReferenceSchema to define the structure for referencing models, including their name, configuration schema, info, version, and specific configuration.
  • JSON Schema Synchronization: Synchronized genkit-schema.json to reflect all type definition changes, including the new MiddlewareDesc and ModelReference schemas, updated GenerationCommonConfig properties, and explicit listing of all part types within MessageSchema content.

🧠 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
  • genkit-tools/common/src/types/common.ts
    • Added MiddlewareDescSchema and MiddlewareDesc for defining middleware descriptors.
  • genkit-tools/common/src/types/index.ts
    • Exported new common types, including middleware descriptors.
  • genkit-tools/common/src/types/model.ts
    • Removed redundant PartSchema imports/exports.
    • Introduced ModelReferenceSchema for model references.
    • Re-defined PartSchema to include all specific part types (Text, Media, ToolRequest, ToolResponse, Data, Custom, Reasoning, Resource).
    • Removed longRunning property from ModelInfoSchema.
    • Enhanced GenerationCommonConfigSchema with detailed descriptions, an apiKey field, and passthrough behavior.
    • Added resources field to GenerateActionOptionsSchema.
  • genkit-tools/common/src/types/parts.ts
    • Added TextPart and ToolRequest type exports.
    • Updated description for TextPartSchema from 'document' to 'message'.
    • Added JSDoc comments for ToolResponseSchema and ToolResponsePart.
    • Simplified PartSchema to only union TextPartSchema and MediaPartSchema.
  • genkit-tools/genkit-schema.json
    • Added resources field to GenerateActionOptions.
    • Expanded MessageSchema content items to explicitly list all part types using anyOf.
    • Enhanced GenerationCommonConfigSchema with detailed descriptions, an apiKey field, and allowed additional properties.
    • Removed longRunning from ModelInfoSchema.
    • Added ModelReference schema.
    • Simplified the top-level Part schema definition.
  • js/ai/src/model.ts
    • Imported and re-exported additional part schemas and types, including MultipartToolResponse, ReasoningPart, and ResourcePart.
  • js/ai/src/parts.ts
    • Added TextPart and ReasoningPart type exports.
    • Updated description for TextPart.
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

The pull request updates model and middleware types, and introduces a new common.ts file for MiddlewareDescSchema. It also refactors PartSchema in model.ts and parts.ts to improve clarity and consistency. Additionally, ModelReferenceSchema is added, and GenerationCommonConfigSchema is enhanced with descriptions and an apiKey field. The genkit-schema.json file is updated to reflect these changes, including the addition of resources to GenerateActionOptions and a more detailed content definition for GenerateResponseChunk.

@MichaelDoyle
Copy link
Member Author

@huangjeff5 what do we need to do about the python errors? I don't think this should necessarily be causing an error. Either there is a problem in the translation step, or the rule needs to be relaxed?

@MichaelDoyle MichaelDoyle force-pushed the update-tools branch 2 times, most recently from 99442ef to 60dc9a6 Compare February 20, 2026 14:33
@MichaelDoyle MichaelDoyle force-pushed the update-tools branch 5 times, most recently from 42c50d2 to 6b27c03 Compare February 20, 2026 17:35
@MichaelDoyle MichaelDoyle requested a review from ssbushi February 20, 2026 17:41
@huangjeff5
Copy link
Contributor

@huangjeff5 what do we need to do about the python errors? I don't think this should necessarily be causing an error. Either there is a problem in the translation step, or the rule needs to be relaxed?

Looking

@MichaelDoyle MichaelDoyle force-pushed the update-tools branch 2 times, most recently from 3d7b8b2 to 3b0adae Compare February 20, 2026 20:45
@github-actions github-actions bot added the python Python label Feb 20, 2026
@MichaelDoyle MichaelDoyle force-pushed the update-tools branch 6 times, most recently from c89d0ef to 0295800 Compare February 20, 2026 22:18
*/
export type ToolResponse = z.infer<typeof ToolResponseSchemaBase> & {
content?: Part[];
content?: DocumentPart[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this change?

Copy link
Member Author

@MichaelDoyle MichaelDoyle Feb 20, 2026

Choose a reason for hiding this comment

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

There is a collision with multiple definitions of Part (models.ts, parts.ts) as both get exported, which causes an issue for the JSON schema generation.

Previously this was isolated to documents.ts, but after things got refactored out into parts.ts it became a broader issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

This means we are downgrading from a generic part to only text/media parts, it this intentional?

@MichaelDoyle MichaelDoyle force-pushed the update-tools branch 3 times, most recently from 0e5ee4f to cb7ad0e Compare February 20, 2026 22:48
export const MultipartToolResponseSchema = z.object({
output: z.unknown().optional(),
content: z.array(PartSchema).optional(),
content: z.array(DocumentPartSchema).optional(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants