Currently, when defining clientTools in mastra/client-js, execute is completely ignored. That is, even if llm requests tool-call, execute is never called in client-js.
const clinet = new MastraClient({ baseUrl: 'http://localhost:4111' })const weatherAgent = client.getAgent('weatherAgent');const response = await weatherAgent.stream({ messages, clientTools: { getLocation: { id: 'getLocation', description: 'Get the user location. Always ask for confirmation before using this tool.', inputSchema: z.object({}), execute: async () => { // never called. console.log('called getLocation'); return 'New York'; }, }, }}
const clinet = new MastraClient({ baseUrl: 'http://localhost:4111' })const weatherAgent = client.getAgent('weatherAgent');const response = await weatherAgent.stream({ messages, clientTools: { getLocation: { id: 'getLocation', description: 'Get the user location. Always ask for confirmation before using this tool.', inputSchema: z.object({}), execute: async () => { // never called. console.log('called getLocation'); return 'New York'; }, }, }}
You should call execute in the client-js environment and feed the tool-result back to llm.