[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[AI SDK](/c/ai-sdk/62)

# Prevent multiple tool calls per single step

197 views · 0 likes · 2 posts


marko-4095 (@marko-4095) · 2025-10-29

is there a way to prevent multiple tool calls per single step? For example, I set max step to be 2 and the tool I give is image generation. Now, I can ask the model to generate 4 images and it will do that, basically providing 4 tool inputs in a single step. Then it uses the second step to write something down. 

Does AI sdk provide way to prevent this, or do I need to somehow do it myself? Didn’t find much in the docs.

using ai sdk v5 and my ai call is like this

```
      const result = streamText({
        model: aiClient(modelName),
        system: enhancedSystemPrompt,
        messages: convertToModelMessages(messages),
        maxOutputTokens,
        temperature,
        tools: {
          ...tools,
        },
        stopWhen: stepCountIs(2),
        onError: (error) => {
          console.error("Error streaming", error);
        },
      });

```


marko-4095 (@marko-4095) · 2025-10-29

I tried setting `parallel_tool_calls` in `providerOptions` but that doesn’t seem to work.

```
      const result = streamText({
        model: aiClient(modelName),
        system: enhancedSystemPrompt,
        messages: convertToModelMessages(messages),
        maxOutputTokens,
        temperature,
        tools: {
          ...tools,
        },
        stopWhen: stepCountIs(2),
        providerOptions: {
          openai: {
            parallel_tool_calls: false,
          },
        },
        onError: (error) => {
          console.error("Error streaming", error);
        },
      });

```