Skip to main content

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. 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.
Install the skill once in your coding-agent environment:
Run the framework-specific prompt below from the application root. Review the resulting diff before deploying it.

Manual setup: Agnost AI SDK

Use the SDK when a task calls a model through anything other than the Vercel AI SDK, or when you want one Agnost AI event per task run.
await agnost.flush() sends the event before the run returns. Trigger.dev can pause, checkpoint, or reuse the worker process after a run, so do not rely on a later flush. Do not call agnost.shutdown() inside run: a reused worker would stop sending events for later runs. Set AGNOST_ORG_ID in your Trigger.dev project’s environment variables.

Manual setup: OpenTelemetry

Trigger.dev runs every task inside its own OpenTelemetry tracer. Add an OTLP exporter to telemetry.exporters in trigger.config.ts and Trigger.dev sends a copy of every run’s spans to Agnost AI. The Vercel AI SDK spans inside a task (model calls, agent steps, and tool calls) carry GenAI attributes, so Agnost AI turns them into events. Trigger.dev’s own run and attempt spans are not ingested.

1. Install

Match the exporter to the OpenTelemetry release your @trigger.dev/sdk uses. @trigger.dev/sdk 4.8 pins @opentelemetry/api 1.9.1 and the 0.219 exporters. The newest exporters need @opentelemetry/api 1.10 and fail to install next to it. To check your version, run npm ls @opentelemetry/exporter-trace-otlp-http and use the same number for @opentelemetry/exporter-trace-otlp-proto. Skip @ai-sdk/otel on AI SDK 5 or 6.

2. Add the Agnost AI exporter to trigger.config.ts

Already exporting to another backend? Add the Agnost AI exporter to the existing exporters array. Trigger.dev sends spans to every exporter in the list. Pass the exporter options in the constructor. Trigger.dev does not support configuring exporters with OTEL_* environment variables, because they conflict with its internal telemetry.

3. Trace AI SDK calls with user and session IDs

AI SDK 7 emits spans only through the @ai-sdk/otel adapter. Register it once at the top of the task file, then pass the user and conversation IDs as runtime context:
AI SDK 7 leaves runtime context out of spans unless each field is listed in includeRuntimeContext. Keep secrets out of that list. On AI SDK 5 or 6, ai emits the spans itself. Do not register @ai-sdk/otel. Pass the IDs as telemetry metadata instead:

What appears in Agnost AI

  • Conversations grouped by sessionId. Runs that share a sessionId land in one conversation.
  • User-level analytics grouped by userId.
  • Events for each AI SDK agent call, agent step, and model call, plus one tool event per tool call with its arguments and result.

Verify

Trigger one run of the task from the Trigger.dev dashboard or with tasks.trigger("support-agent", payload). Then open Events in Agnost AI and confirm the model and tool events arrived with your user ID. Open Conversations and confirm the run is grouped under the conversationId you passed.

Troubleshooting

  • No events, but the run trace shows AI spans: confirm the exporter is in telemetry.exporters and AGNOST_ORG_ID is set in the Trigger.dev environment the task runs in (dev, staging, or prod).
  • No AI spans anywhere: on AI SDK 7, confirm registerTelemetry(new OpenTelemetry(...)) runs in a file the task imports. On AI SDK 5 or 6, confirm experimental_telemetry.isEnabled is true.
  • Events arrive without a user or conversation: on AI SDK 7, list userId and sessionId in includeRuntimeContext and create the adapter with runtimeContext: true.
  • npm install fails with an @opentelemetry/api peer conflict: install the exporter version that matches @trigger.dev/sdk (see step 1).
  • Use @opentelemetry/exporter-trace-otlp-proto with the full /v1/traces URL.
  • Model calls made with a provider’s own SDK or raw fetch produce no AI spans. Use the Agnost AI SDK path for those tasks.

References

Next steps

  • Conversations: review the complete Trigger.dev run.
  • Events: inspect model, step, and tool events from each run.
  • Patterns: organize production conversations by what users wanted.