Agent tracing from system prompt to final output

Building with AI is unreliable. A dozen things can go wrong per run. Sentry traces the whole execution, linked to your app context, so you see the session, the run, and where it broke.

Sentry agent tracing waterfall showing gen_ai spans alongside HTTP, database, and queue spans

See agent decisions and broader application context all in one trace

A bad agent response might stem from a slow database query, a failed API call, or a frontend timeout. Your gen_ai.* spans appear within your existing application traces. Model calls, tool executions, and handoffs sit alongside your regular HTTP, database, and queue spans in the same hierarchy.

Agent Tracing Docs
Sentry trace waterfall showing agent spans alongside application spans

Replay every user session as a readable conversation

Sentry Conversations view showing a chat-like replay of an AI assistant session

Conversations turn raw AI spans into a chat-like replay of any user session with your AI assistant. See the full message history as the user experienced it: inputs, responses, and tool calls in order. Click any message to jump to the underlying LLM generation and tool execution spans with timing and error context.

Learn about Conversations

Know what your agents cost and where the tokens go

Pre-built dashboards show agent runs, error rates, model costs, token breakdowns (input, output, cached, reasoning), and per-tool execution stats. See which models are expensive, which tools fail often, and whether your prompt caching is working.

See AI dashboard docs
Sentry AI Agents Overview dashboard showing agent runs, LLM calls, duration, token usage, and cost charts

Find the tool that's quietly breaking your agent

Sentry AI Agents Tool Details view showing tool call frequency, error rates, and latency

Surface per-tool error rates, P95 latency, and invocation frequency. A tool failing 5% of the time may not move your overall error rate, but it causes 1 in 20 agent runs to produce bad output. Catch it here first.

See AI dashboard docs

Sentry played a significant role in helping us develop [Claude] Sonnet

Nova DasSarma

Systems Lead,

Anthropic

Read the case studyAnthropic testimonial
Getting Started Platforms Scrolling Logo Background Getting Started Platforms Scrolling Logo Background Getting Started Platforms Scrolling Logo Background Getting Started Platforms Scrolling Logo Background Getting Started Platforms Scrolling Logo Background Getting Started Platforms Scrolling Logo Background

Getting started is a few lines of code

Auto-instrumentation for Python and JavaScript. Install the SDK, enable tracing, start sending AI spans. Spans and dashboards populate automatically.

Python
import sentry_sdk

sentry_sdk.init(
    dsn="___DSN___",
    traces_sample_rate=1.0,
    send_default_pii=True,
)
Python
from agents import Agent, Runner

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
)

result = Runner.run_sync(agent, "Hello!")
JavaScript
const Sentry = require("@sentry/node");

Sentry.init({
  dsn: "___DSN___",
  tracesSampleRate: 1.0,
  integrations: [Sentry.vercelAIIntegration()],
});
JavaScript
const { generateText } = require("ai");
const { openai } = require("@ai-sdk/openai");

const result = await generateText({
  model: openai("gpt-4o"),
  prompt: "Hello!",
  experimental_telemetry: { isEnabled: true },
});
JavaScript
// sentry.server.config.ts
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: "___DSN___",
  tracesSampleRate: 1.0,
  integrations: [Sentry.vercelAIIntegration()],
});
JavaScript
// app/api/chat/route.ts
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const result = await generateText({
  model: openai("gpt-4o"),
  prompt: "Hello!",
  experimental_telemetry: {
    isEnabled: true,
    recordInputs: true,
    recordOutputs: true,
  },
});
Python
import sentry_sdk
from sentry_sdk.integrations.langchain import LangchainIntegration

sentry_sdk.init(
    dsn="___DSN___",
    traces_sample_rate=1.0,
    send_default_pii=True,
    integrations=[LangchainIntegration()],
)
Python
from langchain.chat_models import init_chat_model
model = init_chat_model("gpt-4o", model_provider="openai")

response = model.invoke("Hello!")
Python
import sentry_sdk

sentry_sdk.init(
    dsn="___DSN___",
    traces_sample_rate=1.0,
    send_default_pii=True,
)
Python
from langgraph.graph import StateGraph, END
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o")
graph = StateGraph(dict)
# Define your graph nodes and edges
app = graph.compile()

result = app.invoke({"input": "Hello!"})

Agent tracing FAQs

Agent tracing follows a single AI agent run from start to finish as a connected trace, capturing every LLM call, tool execution, MCP interaction, and handoff as a span with its inputs, outputs, token counts, cost, and timing. Because agents make decisions across many steps, a flat log isn't enough: agent tracing shows the full execution path so you can see exactly which step failed or stalled. See how agent tracing works in Sentry.

LLM monitoring measures individual model calls: latency, tokens, errors. Agent tracing tracks the complete agent lifecycle: multi-step reasoning, tool execution, sub-agent transfers, and how individual calls combine into workflows. Sentry does both. Individual LLM call data feeds into the same traces and dashboards as the full agent execution.

Sentry agent tracing is complementary to eval workflows. Evals catch regressions against known test cases; agent traces show you the execution behind the score — which model was called, what the tool returned, where context was lost. When an eval flags a quality drop, the trace tells you why, and when something breaks that you didn't write an eval for, traces are how you find it first. Read more about evals and traces.

Yes. Agent traces are part of your existing Sentry distributed traces. Your gen_ai.* spans appear alongside your HTTP, database, and queue spans in the same trace hierarchy. No separate product, no additional system. Add the SDK integration for your agent framework and agent spans start appearing in traces you already have.

Sentry auto-instruments OpenAI Agents, Vercel AI SDK, LangChain, LangGraph, Pydantic AI, Anthropic SDK, Google GenAI, and more — in both Python and JavaScript/Node.js. If your framework isn't auto-instrumented, manual instrumentation takes about 10 lines per span type. See the full list.

Yes. MCP tool calls appear as gen_ai.execute_tool spans inside your agent traces. You see which MCP servers were called, what data they returned, how long they took, and whether they errored — all connected to the agent run that triggered them. Get started with MCP observability.

Conversations turns raw AI spans into a chat-like replay of any user session with your AI assistant. See the full message history as the user experienced it, and click any message to see the underlying spans. A single conversation can span multiple traces, Sentry stitches them using a stable gen_ai.conversation.id.

Yes. Agent tracing, dashboards, and cost tracking are available on every Sentry plan, including the free Developer plan. See pricing.

More on agent tracing

Fix with full-stack context

Get started with the only application monitoring platform where your agent traces live alongside your existing errors, logs, and session replays.