Skip to main content
Debugging Vercel AI SDK workflows in production is painful. console.log disappears into serverless cold starts. Streaming responses have no visibility past the first token. Tool calls fail silently. npm install tracepilot-vercel gives you structured traces, replay, and full span visibility — in under five minutes.

Why traditional logs fail for Vercel AI SDK

Serverless functions on Vercel have hard limits that make conventional debugging brittle: TracePilot solves all of these by wrapping your AI SDK calls and shipping structured spans to a persistent dashboard — even across serverless boundaries.

Real-world debugging scenario

You ship a RAG pipeline using generateText with two tool calls. It works in staging. In production, 12% of requests return empty outputs. No errors in Vercel logs. With TracePilot, you open the dashboard, filter for failed traces, and immediately see:
  • Span 1 (generateText) completed in 1.2s ✓
  • Span 2 (fetchDocument) timed out at 3.0s ✗
  • Span 3 (generateText) never fired — skipped due to empty tool output
One dashboard view. No log archaeology.

Installation

yarn

Environment variables

.env.local
Never commit your API key. Use .env.local for local development and Vercel environment variables for production deployments.

Instrumenting generateText()

Wrap your generateText call with TracePilot. Your existing code stays unchanged — the wrapper captures input, output, token usage, and latency as a span.

Instrumenting streamText()

Streaming is where most Vercel AI SDK debugging tools fall short. TracePilot captures the full stream — start time, first token latency, full output, and any mid-stream errors.
wrapStream does not buffer the stream. It taps it transparently — your time-to-first-token is unaffected.

Wrapper instrumentation for multi-tool pipelines

Chain spans with parentSpanId to build a full execution tree across multiple generateText and tool calls.
The dashboard renders this as a three-level tree: Plan → Fetch → Answer. If Fetch fails, the failure is isolated immediately.

Replay AI execution

Once a trace is captured, you can fork any span and re-run it with modified inputs — directly from the dashboard. No redeployment. No code changes. How to replay a failing Vercel AI SDK span:
1

Open the trace

Go to tracepilotai.com/dashboard and find the failing trace. Traces are sorted by recency and filterable by status.
2

Select the failing span

Click into the span where the failure occurred. You’ll see the exact input messages, model parameters, token count, and error output.
3

Fork & Rerun

Click Fork & Rerun. Edit the prompt, adjust the model, or change tool parameters. Hit Run — TracePilot re-executes the span and shows you the new output side-by-side.
4

Deploy the fix

Once you’ve confirmed the fix works in replay, apply the change to your codebase and ship.
Screenshot pending: TracePilot dashboard showing a forked Vercel AI SDK trace with side-by-side comparison.

Vercel AI SDK observability checklist

Make sure you’re passing the result of tp.wrapGenerate() and not calling generateText() directly. The wrapper must intercept the call to record the span.
wrapStream captures the full stream asynchronously. If the trace shows an empty output, the stream may have been consumed before TracePilot could read it. Ensure you’re passing the wrapped stream to StreamingTextResponse, not the raw one.
Verify TRACEPILOT_API_KEY is set in your Vercel project environment variables — not just in .env.local. Local env files are not deployed.
TracePilot batches and ships spans before the function returns. If your function hits the Vercel timeout limit (default 10s), increase it in vercel.json or use Edge Runtime.

Next steps

Quickstart: tracepilot-vercel

Go from install to live trace in under 5 minutes.

Time-travel debugging

Learn the full Fork & Rerun flow for fixing broken spans.

Multi-step agents

Build nested span trees across complex pipelines.

Cost tracking

Monitor token spend per span across all your AI SDK calls.