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.
Estimate your project cost, token budget, and automation ROI
We built free, production-calibrated tools to help engineering leaders forecast token consumption, compare build vs buy scenarios, and audit code security.
Work with us on this
Expert consulting for the Vercel AI SDK. We help engineering teams design and scale AI architectures that won't break in production.
Vercel AI SDK IntegrationSeamlessly integrate Vercel AI SDK into your existing React, Next.js, or Node.js applications. We build the features so your team can focus on the core product.
Vercel AI SDK MigrationUpgrade your legacy AI wrappers or older SDK versions to Vercel AI SDK v7. We handle the breaking changes so your application stays stable.
Related reading
Traditional APM tools monitor request-response latency and error codes. Autonomous agents fail because of semantic drift, silent backtracking, and corrupting side effects. Here is how to build immutable action-audit chains that actually explain agent decisions.
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.
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.