Skip to content

@ai-sdk/google-vertex/maas Llama 4 Scout returns tool calls as plain JSON text #15687

Description

@kdawgwilk

Description

Vertex MaaS Llama 4 Scout does not produce AI SDK tool calls through createVertexMaas. Instead, it returns a JSON-looking tool call as plain assistant text.

Llama 4 Maverick with the same provider configuration and tool definition produces real AI SDK toolCalls and toolResults.

Reproduction

import { createVertexMaas } from '@ai-sdk/google-vertex/maas';
import { generateText, tool } from 'ai';
import { z } from 'zod/v4';

const project = process.env.GOOGLE_VERTEX_PROJECT!;

const provider = createVertexMaas({
  project,
  location: 'us-east5',
  baseURL:
    `https://us-east5-aiplatform.googleapis.com/v1/projects/${project}/locations/us-east5/endpoints/openapi`,
  fetch: async (url, init) => {
    if (init?.body && typeof init.body === 'string') {
      const body = JSON.parse(init.body);
      if (body.max_tokens === undefined && body.max_completion_tokens === undefined) {
        return fetch(url, {
          ...init,
          body: JSON.stringify({ ...body, max_tokens: 4096 }),
        });
      }
    }

    return fetch(url, init);
  },
});

const result = await generateText({
  model: provider('meta/llama-4-scout-17b-16e-instruct-maas'),
  prompt: 'Call the weather tool for Denver.',
  tools: {
    weather: tool({
      description: 'Get weather',
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => `weather-ok:${city}`,
    }),
  },
});

console.log({
  text: result.text,
  toolCalls: result.toolCalls.length,
  toolResults: result.toolResults.length,
  finishReason: result.finishReason,
});

Observed result:

{
  "text": "{\"name\": \"weather\", \"parameters\": {\"city\": \"Denver\"}}",
  "toolCalls": 0,
  "toolResults": 0,
  "finishReason": "stop"
}

Control with Maverick:

model: provider('meta/llama-4-maverick-17b-128e-instruct-maas')

Observed control result:

{
  "text": "",
  "toolCalls": 1,
  "toolResults": 1,
  "finishReason": "tool-calls"
}

Expected behavior

If Llama 4 Scout supports OpenAI-compatible tool calling on Vertex MaaS, generateText should populate result.toolCalls.

If Scout does not support tool calling, the provider/docs should make that clear so applications can avoid sending tool definitions to this model.

Actual behavior

Scout returns a JSON-like function call as plain text, leaving toolCalls and toolResults empty.

Package versions

  • @ai-sdk/google-vertex: 4.0.140
  • ai: 6.0.78
  • Node.js: 24.11.1

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions