
Finding Slow Tool Calls in Vercel AI SDK v7 Telemetry
When an agent takes ten seconds to respond, you need to know why. I used the new OpenTelemetry support in Vercel AI SDK v7 to track down a slow API call.
A lot of AI demos look incredibly fast until you run them in production. My weather-checking agent worked perfectly locally, but users complained it was freezing for ten seconds before typing a response.
Before Vercel AI SDK v7, debugging latency meant littering my code with console.time(). The new @ai-sdk/otel package fixes this by hooking directly into Node.js tracing channels.
Wiring up OpenTelemetry
You have to configure an OpenTelemetry provider first. I exported my traces to a local Jaeger instance to visualize them. The SDK handles the rest automatically once you import the instrumentation module.
// instrumentation.ts
import { registerOTel } from '@vercel/otel';
import { AISDKExporter } from '@ai-sdk/otel';
export function register() {
registerOTel({
serviceName: 'weather-agent',
traceExporter: new AISDKExporter(),
});
}
// agent.ts
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { z } from 'zod';
export async function POST(req: Request) {
return streamText({
model: openai('gpt-4o'),
prompt: 'What is the weather in London?',
tools: {
getWeather: {
description: 'Get current weather',
parameters: z.object({ city: z.string() }),
execute: async ({ city }) => {
// This API call was the culprit
const res = await fetch(`https://api.slow-weather.com/v1/${city}`);
return res.json();
},
},
},
});
}
Reading the Traces
When I checked the Jaeger dashboard, the problem was obvious. The trace showed the initial LLM call took 800 milliseconds. Then there was a massive eight-second block labeled tool-execution: getWeather. The final LLM call to format the response took another 600 milliseconds.
The model was not slow. The external weather API I was using had terrible latency.
The v7 observability features give you a granular breakdown of every step: how long the model thought, how long the tool ran, and how long the stream took to close. If you are building agents that rely on third-party APIs, this level of tracing is not optional. You have to know what is actually slowing you down.
Related reading
Our monthly client reports followed a 40-line prompt nobody dared touch. I moved the whole playbook into an uploaded skill using the new uploadSkill API in Vercel AI SDK v7.
Voice agents used to mean marrying one provider's WebSocket event format. I used the new experimental realtime API in Vercel AI SDK v7 to build an order-status voice agent I can move between providers.
I built a dependency-audit agent that runs npm commands on real projects. The new experimental sandbox support in Vercel AI SDK v7 is what made me comfortable shipping it.
Next Article
Let's build something great.
Have a project in mind? We are an elite software and AI development studio ready to bring your ideas to production. Let's talk about your roadmap.