instrumentAgent() is a non-mutating wrapper that adds telemetry to any existing agent without changing its definition. Inline telemetry via AgentOptions.telemetry configures tracing directly on the agent at construction time. Both approaches delegate entirely to the Vercel AI SDK’s experimental_telemetry - Vibes does not create custom spans.
Use instrumentAgent() when you want to add tracing to an agent you didn’t define (a shared utility, a library agent). Use inline telemetry when you own the agent and prefer to configure tracing at construction time.
OTel span hierarchy
Each model call (one per agent turn) gets its owngenerateText span. Each tool invocation gets a child span under that turn’s span. The exact span names and attributes follow the Vercel AI SDK telemetry convention and may vary by SDK version.
instrumentAgent()
instrumentAgent() wraps an existing agent and returns an object with the same three run methods (run, stream, runStreamEvents). The original agent is never mutated.
instrumentAgent() uses agent.override() internally - it never mutates the original agent and is safe to reuse across requests.
Inline telemetry on AgentOptions
Configure telemetry directly on the agent constructor using thetelemetry option. TelemetrySettings is the Vercel AI SDK type:
telemetry field accepts the same TelemetrySettings shape that the Vercel AI SDK accepts on generateText. All span creation is handled by the AI SDK.
Content exclusion for GDPR
When you need to trace agent execution without recording the content of prompts or model outputs (for GDPR, PII, or compliance reasons), setexcludeContent: true on instrumentAgent:
excludeContent: true, spans are still created for every turn and tool call - you retain execution structure, latency, and token counts - but the actual text content is omitted from span attributes.
What spans are created
Vibes delegates span creation entirely to the Vercel AI SDK’sexperimental_telemetry. The framework passes your TelemetrySettings or InstrumentationOptions through to each generateText call.
What the AI SDK creates per agent run:
- One span per model call (one per agent turn)
- One child span per tool invocation within a turn
Vibes does not create custom spans. All span naming follows the Vercel AI SDK telemetry convention. Consult the Vercel AI SDK telemetry docs for current span names and attribute schemas.
API reference
| Symbol | Type | Description |
|---|---|---|
instrumentAgent | (agent, options) => { run, stream, runStreamEvents } | Wraps an agent with telemetry; returns the same interface as the original agent |
InstrumentationOptions | interface | { functionId: string, metadata?: Record<string, unknown>, excludeContent?: boolean, isEnabled?: boolean } |
TelemetrySettings | interface (from "ai") | { isEnabled: boolean, functionId: string, recordInputs: boolean, recordOutputs: boolean } - passed directly to Vercel AI SDK |