Empty args in tool-call when using clientTools

The reproduction procedure is as follows

  1. initialize the mastra project by running npx create-mastra@latest
  2. Run npm run dev to start the mastra server
  3. Run the following script
import { MastraClient } from "@mastra/client-js";
import { weatherTool } from "./mastra/tools/weather-tool";

const client = new MastraClient({
  baseUrl: "http://localhost:4111",
});

const weatherAgent = client.getAgent("weatherAgent");

const response = await weatherAgent.stream({
  messages: [
    {
      role: "user",
      content: "What is the weather in Tokyo?",
    },
  ],
  clientTools: {
    weatherTool,
  }
});

const reader = response.body?.getReader();

if (!reader) {
  throw new Error('Failed to get reader');
}

// eslint-disable-next-line no-constant-condition
while (true) {
  const { done, value } = await reader.read();
  if (done) {
    break;
  }
  const chunk = new TextDecoder().decode(value);
  console.log(chunk);
}


The following logs will appear.

 $ npx tsx ./src/script.ts                                                                                         14:47:19
f:{"messageId":"msg-w5VPp01uOjM0jpD8Cf8e13G7"}
9:{"toolCallId":"Ldxg53gOJu7jGzcp","toolName":"weatherTool","args":{}}

e:{"finishReason":"tool-calls","usage":{"promptTokens":146,"completionTokens":2},"isContinued":false}
d:{"finishReason":"tool-calls","usage":{"promptTokens":146,"completionTokens":2}}
Was this page helpful?