-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
While working on a new workflow project, running into the issue with tool call definitions. This is the recommended way that AI sdk tools are written. i.e. the execute function is an arrow function inside the tool definition, which would need the "use step"
import { tool } from 'ai';
import { z } from 'zod';
export const weatherTool = tool({
description: 'Get the weather in a location',
parameters: z.object({
location: z.string().describe('The location to get the weather for'),
}),
execute: async ({ location }) => {
'use step';
const response = await fetch(
`https://api.weather.com/v1/current?location=${location}`
);
return response.json();
},
});However, we don't currently support this in the SWC transform - we only support root level steps and workflows
@ijjk I know we earlier spoke about not supporting this and enforcing the top level export but wondering if you have thoughts here? I would like to support this pattern to align with AI sdk best practices. I believe the "use server" directive in Next.js works correctly. Am afraid this gets complicated with closure tracking, etc. and am curious on your thoughts
Metadata
Metadata
Assignees
Labels
No labels