GenkitG
Genkitโ€ข5mo ago
skinny-azure

googleSearchRetrieval in Genkit with structure output

Hello guys,

I am trying to use googleSearchRetrieval in Genkit with structure output.
Most of the time it return
{ queries: [] }

instead of output schema and the model stopped with the following error.

GenkitError: INVALID_ARGUMENT: Schema validation failed. Parse Errors:

- (root): must have required property 'data'

Provided data:

{
  "queries": []
}

Required JSON schema:

{
  "type": "object",
  "properties": {
    "data": { etc...


When I debug in Trace viewer in Firebase Genkit ui, I found
<ctrl42>call:google_search.search{queries:[]}<ctrl43><ctrl44>


at the bottom of think process that I think it might related to the error.

I have tried switching model between 2.5 flash and 2.5 pro, but the error still happens.
I upgraded genkit to latest version.

here is my code
const { stream: streamResponse, response: promiseResponse } = prompt.stream(
    input,
    {
        messages: context,
        output: {
            format: 'json',
            schema: outputSchema,
        },
        config: {
            googleSearchRetrieval: {},
            thinkingConfig: {
                thinkingBudget: THINKING_BUDGET,
                includeThoughts: true,
            },
        },
    },
)


Please help me to fix this issue.
Was this page helpful?