Choose a setup method
Start with one method for a call path. Combining SDK tracking with framework
OpenTelemetry on the same call can create duplicate interactions.
Recommended: Agnost AI skill
Recommended. Choose this path when you want your coding agent to inspect the
project, select a supported transport, make the smallest instrumentation change,
send a test event, and verify that it reached Agnost AI.
@copilotkit/runtime/v2) with a
BuiltInAgent in factory mode, where your code owns the streamText() call.
If your CopilotRuntime fronts an agent built with another framework, such as
LangGraph, Mastra, CrewAI, Agno,
or Pydantic AI, instrument that agent with its own guide.
Manual setup: Agnost AI SDK
Record one event per agent run. The CopilotKit thread becomes the Agnost AI conversation.agents factory runs once per request, so each run knows the signed-in
user. Serve runtime with your usual CopilotKit endpoint, for example
createCopilotRuntimeHandler, createCopilotNodeListener, or the Express and
Hono adapters.
Call await agnost.shutdown() once when the application exits, not after each request.
Manual setup: OpenTelemetry
The Vercel AI SDK inside a factory-modeBuiltInAgent emits ai.* spans for
each run, model step, and tool call. Send them to Agnost AI and put the
CopilotKit threadId and your user ID in the telemetry metadata.
Install
@copilotkit/runtime 1.90 depends on ai 6.x. Install the same major so your
factory and the runtime share one copy of the AI SDK.
Already have @opentelemetry/sdk-node and an OTLP exporter? Install only the
CopilotKit and AI SDK packages.
No OTel set up yet?
Setup
1. Start the OTel SDK before the runtime loads (for example in Next.jsinstrumentation.ts, or the first import of your server entry file):
BatchSpanProcessor above to the
spanProcessors array of your existing NodeSDK or tracer provider.
2. Turn on AI SDK telemetry in the factory:
metadata.sessionId and metadata.userId become ai.telemetry.metadata.sessionId
and ai.telemetry.metadata.userId on every span. Agnost AI uses them for
conversation grouping and user attribution. convertToolsToVercelAITools(input.tools)
passes the frontend tools registered in the browser; server tools such as
getWeather run on the server and show up as tool events.
What appears in Agnost AI
- Conversations grouped by the CopilotKit
threadId. - User-level analytics grouped by the user ID you put in
metadata. - Events for each run (
ai.streamText), each model step (ai.streamText.doStream), and each server tool call (named after the tool).
Verify
Send one chat message through your CopilotKit UI, then open Conversations in Agnost AI. Confirm the conversation uses the thread ID, has your user ID, and shows the user message and assistant reply. If the agent called a server tool, confirm a tool event with its arguments and result.Troubleshooting
- Start the OTel SDK before
@copilotkit/runtimeandaiare imported. Spans created beforeotelSdk.start()are not exported. - Use
BuiltInAgentwithtype: 'aisdk'. The classic config (model: 'openai/...') callsstreamText()without telemetry, so noai.*spans are created. - Keep
aion the major version that@copilotkit/runtimedepends on (6.x for 1.90). AI SDK 7 uses a different telemetry API. - Confirm
X-Agnost-Org-IDis set on the exporter and the URL ends in/v1/traces. - In short-lived scripts, call
await otelSdk.shutdown()before exit so the batch is flushed.
References
Next steps
- Conversations: review each CopilotKit thread as one conversation.
- Events: inspect model steps and tool calls.
- Patterns: organize production conversations by what users wanted.