Skip to main content
Trace an agent built on @anthropic-ai/claude-agent-sdk by pointing the engine’s OpenTelemetry export at RunAgain. For guaranteed token/cost columns you can also wrap each run in a manual span with the runagain SDK.

Install

Configure

.env.local

Point the engine at RunAgain

The Claude Agent SDK runs the Claude Code engine, which can export its own OTLP spans. Pass RunAgain’s endpoint + key into the query’s env and it streams runs, tool calls and tokens to your project:
agent.ts
Open your project’s Traces page to see the runs stream in.

Guaranteed token & cost columns

The engine’s beta export can lag; to always land the numeric columns (and add your own identity/metadata), initialize the runagain SDK once at startup and wrap each run in an invoke_agent span, reading token usage off the SDK’s result message:
A complete reference (per-tool execute_tool spans, error handling) lives in the runagain-test-agents harness (src/agents/claude).
Prefer to let your coding agent wire this up? Paste into Claude Code or Cursor: “Integrate RunAgain into this Claude Agent SDK project — install runagain, pass the OTLP telemetry env into my query() calls, and read RUNAGAIN_API_KEY / RUNAGAIN_INGEST_URL from env. Keep my agent logic unchanged.”