Skip to content

toolChoice is ignored when using a model via Vercel's AI SDK #239

@eapariciodev

Description

@eapariciodev

I'm using a non-OpenAI model via Vercel's AI SDK as outlined on this page: https://openai.github.io/openai-agents-js/extensions/ai-sdk/

The issue is that it is impossible to force the model to use a tool because the toolChoice setting is not passed to the model at all.

const aiSdkRequest: LanguageModelV1CallOptions = {
inputFormat: 'messages',
mode: {
type: 'regular',
tools,
},
prompt: input,
temperature: request.modelSettings.temperature,
topP: request.modelSettings.topP,
frequencyPenalty: request.modelSettings.frequencyPenalty,
presencePenalty: request.modelSettings.presencePenalty,
maxTokens: request.modelSettings.maxTokens,
responseFormat,
abortSignal: request.signal,
...(request.modelSettings.providerData ?? {}),
};

I believe it would need to be added to mode. If I want toolChoice='required' then the SDK is expecting something like

mode: {
  ...,
  toolChoice: { type: 'required' }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions