Tap on the default suggested action for What is the weather in San Fancisco?
Issue should be reproducible by now, and following is what you're seeing.
Once the form is back submittable, you can send any text and the API would return this error;
⨯ AI_MessageConversionError: ToolInvocation must have a result: {"state":"call","toolCallId":"call_SAOMz3pWx9TpOZvqFswmxA5F","toolName":"getWeather","args":{"latitude":37.7749,"longitude":-122.4194}}
Code example
const result = await streamText({
model: customModel,
system:
"you are a friendly assistant! keep your responses concise and helpful.",
messages: coreMessages,
maxSteps: 5,
tools: {
getWeather: {
description: "Get the current weather at a location",
parameters: z.object({
latitude: z.number(),
longitude: z.number(),
}),
execute: async ({ latitude, longitude }) => {
const response = await fetch(
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`,
);
const weatherData = await response.json();
return weatherData;
},
},
},
onFinish: async ({ responseMessages }) => {
if (session.user && session.user.id) {
try {
await saveChat({
id,
messages: [...coreMessages, ...responseMessages],
userId: session.user.id,
});
} catch (error) {
console.error("Failed to save chat");
}
}
},
experimental_telemetry: {
isEnabled: true,
functionId: "stream-text",
},
});
return result.toDataStreamResponse({});
Additional context
For additional context, this issue does not seem to be reproducible for me on Node v18.19.0. I am not sure about the other node versions yet.
Description
First of all, make sure that you're running on Node v20.10.0, then follow this step:
pnpm dev
What is the weather in San Fancisco?
Once the form is back submittable, you can send any text and the API would return this error;
Code example
Additional context
For additional context, this issue does not seem to be reproducible for me on Node v18.19.0. I am not sure about the other node versions yet.