Skip to navigation

AI SDK

Send Vercel AI SDK telemetry to Astropods and optionally serve the agent over Astropods messaging
View as Markdown

Send traces from a Vercel AI SDK agent to Astropods so its model calls, tool calls, and latency appear in the dashboard. You can optionally serve the agent over Astropods messaging to use it in the Astropods playground.

@astropods/adapter-ai-sdk exports two functions you can use independently:

  • astroTelemetry() returns AI SDK experimental_telemetry settings wired to the Astropods OTLP exporter.
  • serve() connects an Experimental_Agent to the Astropods messaging service so your agent works in the Astropods playground.

Targets ai >= 6.0.0.

Before you start

  • A deployable Astropods agent project.
  • Astropods sets OTEL_EXPORTER_OTLP_ENDPOINT only on deployed containers, so traces appear once the agent runs on the platform — not during local development.

Install

bun add @astropods/adapter-ai-sdk

Send telemetry to Astropods

Add astroTelemetry() into the agent’s experimental_telemetry:

import { Experimental_Agent as Agent } from "ai";
import { openai } from "@ai-sdk/openai";
import { astroTelemetry } from "@astropods/adapter-ai-sdk";
const agent = new Agent({
model: openai("gpt-4o"),
instructions: "You are a helpful assistant.",
experimental_telemetry: astroTelemetry(),
});

Traces capture each turn’s model calls, tool calls, and latency, attributed to the deployed agent. Use this on its own when you serve the agent from your own framework and want AI traces reported in the dashboard.

Serve over Astropods messaging

To run the agent on Astropods messaging, pass it to serve():

import { Experimental_Agent as Agent } from "ai";
import { openai } from "@ai-sdk/openai";
import { serve, astroTelemetry } from "@astropods/adapter-ai-sdk";
const instructions = "You are a helpful assistant.";
const agent = new Agent({
model: openai("gpt-4o"),
instructions,
experimental_telemetry: astroTelemetry(),
});
serve(agent, { name: "My Agent", instructions });

Passing instructions into serve() makes your agent’s system prompt visible in the Astropods playground. It’s optional — omit instructions to keep the prompt hidden.

Memory

serve() keeps each conversation’s history in the agent process and sends it to the model with each new message. A follow-up sees the earlier turns, including tool calls and their results. History resets when the agent restarts, and each replica keeps its own. The conversation history in the Astropods playground is stored separately.

These serve() options bound the history:

OptionDefaultEffect
memorytruefalse sends only the new message.
maxTurns20Turns each conversation keeps.
maxHistoryBytes256 KiBSize a conversation’s history may reach, about 64K tokens. Past it, the adapter replaces the oldest tool outputs with a size note, then drops the oldest turns.
maxConversations200Conversations kept. Past it, the adapter forgets the least recently used one.

At the defaults, history uses at most about 50 MB. After a failed turn, the adapter drops the older half of that conversation’s history. A stopped turn changes nothing.

With memory on, the agent receives messages instead of prompt. Set memory: false if the agent’s prepareCall reads prompt, or if the agent keeps its own memory.

Verify

Deploy the agent, send it a message, then open the agent’s detail page in the dashboard. Traces appear within ~30 seconds.

If nothing shows up:

  • Confirm experimental_telemetry: astroTelemetry() is on the agent.
  • Confirm OTEL_EXPORTER_OTLP_ENDPOINT is set in the deployed container.
  • Check the container logs for OpenTelemetry export errors.