-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
wrapAISDK seems to not support new Agent class from v5 of ai-sdk (that will be ToolLoopAgent class in v6)
Any guidance on how to trace it properly with Braintrust? I currently wrap my calls with traced() to group them in the same trace, so I don't know how the OTEL approach can help me as I need to group LLM runs within the same trace
Example of new Agent class usage:
import { Experimental_Agent as Agent, stepCountIs, tool } from 'ai';
import { z } from 'zod';
const weatherAgent = new Agent({
model: 'openai/gpt-4o',
tools: {
weather: tool({
description: 'Get the weather in a location (in Fahrenheit)',
inputSchema: z.object({
location: z.string().describe('The location to get the weather for'),
}),
execute: async ({ location }) => ({
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
}),
}),
convertFahrenheitToCelsius: tool({
description: 'Convert temperature from Fahrenheit to Celsius',
inputSchema: z.object({
temperature: z.number().describe('Temperature in Fahrenheit'),
}),
execute: async ({ temperature }) => {
const celsius = Math.round((temperature - 32) * (5 / 9));
return { celsius };
},
}),
},
stopWhen: stepCountIs(20),
});
const result = await weatherAgent.generate({
prompt: 'What is the weather in San Francisco in celsius?',
});
console.log(result.text); // agent's final answer
console.log(result.steps); // steps taken by the agent
codybrouwers, RDavies8 and grant0417
Metadata
Metadata
Assignees
Labels
No labels