Skip to content

fix(genkit_google_genai)!: wire seed and fileSearch into the request - #393

Draft
cabljac wants to merge 6 commits into
mainfrom
feat/googlegenai-seed-filesearch
Draft

fix(genkit_google_genai)!: wire seed and fileSearch into the request#393
cabljac wants to merge 6 commits into
mainfrom
feat/googlegenai-seed-filesearch

Conversation

@cabljac

@cabljac cabljac commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #363. Stacked on #392 (targets fix/googlegenai-safety-settings-unset).

seed and fileSearch were accepted by GeminiOptions/GeminiTtsOptions but silently dropped when building the request. This wires both: seed is mapped into GenerationConfig in both settings builders, and fileSearch becomes a tool entry - the generated client's hand-authored Tool type gains a fileSearch member via schemaOverrides (the discovery doc has no Tool schema), with the config passed through verbatim, matching the JS plugin. Wire-level tests cover both the standard and TTS paths and pin omission when unset.

The FileSearch config schema is aligned with the JS plugin, which is a breaking change to the exported FileSearch API: fileSearchStoreNames is now required and non-nullable; metadataFilter and topK are added.

Caveat: fileSearch is a Google AI-only feature reachable from the shared GeminiOptions schema; Vertex callers setting it will get the API's error. Flagging the schema layering question for maintainers.

…stead of sending UNSPECIFIED

Unset category fell back to HARM_CATEGORY_UNSPECIFIED on the wire, which
the API rejects with 400 INVALID_ARGUMENT. Filter those entries out and
pass threshold through as-is, omitting it when unset so the server
default applies.

Fixes #365
seed was accepted by GeminiOptions and GeminiTtsOptions but never
mapped into GenerationConfig; fileSearch was accepted but never added
to tools. Map seed in toGeminiSettings and toGeminiTtsSettings, add a
FileSearch tool member to the generated client (hand-authored via
schemaOverrides, since the discovery doc has no Tool schema) and pass
the config through at both toGeminiTools call sites.

Align the FileSearch config schema with the JS plugin:
fileSearchStoreNames is now required, metadataFilter and topK added.

Fixes #363

BREAKING CHANGE: the exported FileSearch() constructor now requires
fileSearchStoreNames, and its getter is non-nullable (previously both
were optional/nullable).
@cabljac cabljac added this to the v1 - stable milestone Aug 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 support for the fileSearch tool and the seed generation configuration option across the genkit_google_genai package, including updates to plugins, generated client code, schema definitions, and corresponding unit tests. The feedback suggests an improvement in common_plugin.dart to directly instantiate gcl.FileSearch using its constructor rather than serializing and deserializing via JSON, which enhances type safety and avoids unnecessary runtime overhead.

Comment thread packages/genkit_google_genai/lib/src/common_plugin.dart Outdated
…ON round trip

The generated FileSearch extension type has a named-argument constructor
whose map literal uses null-aware entries, so unset optional fields are
omitted rather than sent as explicit nulls. Constructing it directly type
checks each field and builds a fresh map, where FileSearch.fromJson wrapped
the caller's own options map and forwarded any explicit null in it to the
wire.
@cabljac cabljac mentioned this pull request Aug 26, 2026
10 tasks
Base automatically changed from fix/googlegenai-safety-settings-unset to main August 26, 2026 14:28
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