Skip to content

Requests to vertex ai fail if z.record(z.string()) used in tool schema #5628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tjenkinson opened this issue Apr 9, 2025 · 1 comment · May be fixed by #5626
Open

Requests to vertex ai fail if z.record(z.string()) used in tool schema #5628

tjenkinson opened this issue Apr 9, 2025 · 1 comment · May be fixed by #5626
Labels
bug Something isn't working

Comments

@tjenkinson
Copy link

Description

See the code example below. When using vertex ai if z.record(z.string()) is used an error occurs because in the generated open api schema something becomes undefined

Code example

import { createVertex } from '@ai-sdk/google-vertex'
import { CoreMessage, Tool, generateText, tool, LanguageModelV1 } from 'ai'

const vertex = createVertex({
  project: ...,
  location: ...,
})

const gemini2Flash: LanguageModelV1 = vertex.languageModel(
  'gemini-2.0-flash-001',
)

await generateText({
  model: gemini2Flash,
  prompt: 'Hi',
  tools: {
    test: tool({
      description: 'Test',
      parameters: z.object({
        // the issue
        something: z.record(z.string())
      }),
    }
  }
})

AI provider

@ai-sdk/google-vertex 2.2.14

Additional context

I opened a PR to fix this here: #5626

@tjenkinson tjenkinson added the bug Something isn't working label Apr 9, 2025
@tjenkinson tjenkinson linked a pull request Apr 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@tjenkinson and others