import { z } from 'zod'; import { Agent, run, tool } from '@openai/agents'; const getWeatherTool = tool({ name: 'get_weather', description: 'Get the weather for a given city', parameters: z.object({ city: z.string() }), execute: async (input) => { return `The weather in ${input.city} is sunny`; }, }); const agent = new Agent({ name: 'Data agent', instructions: 'You are a data agent', tools: [getWeatherTool], }); async function main() { const result = await run(agent, 'What is the weather in Tokyo?'); console.log(result.finalOutput); } main().catch(console.error);