Skip to content

Agent tracing: from user goal to final outcome

Agent tracing is the practice of recording every step an agent takes during a run, each model call, tool invocation, retrieval, handoff and error, so you can see exactly what happened, in order, when something goes wrong or needs to be measured.

By Arun Prasad · Published · Last updated

On this page

Why agent tracing matters

AI agents don't fail like normal software. A tool can return a 200 and the task can still fail. Standard monitoring shows the request went through, not whether the answer was right or whether the agent took the right path.

Consider a simple booking agent. Every API call succeeds. The model responds at every step. No exceptions are raised. And yet the user's flight was booked for the wrong date, because the agent misread the input on step three and nothing downstream caught it.

That failure is invisible to request logging. It's visible in a trace.

Agent tracing captures the full trajectory of a run: what the agent was asked, which steps it took, what each step returned, and what it finally said. That lets you tell the difference between a run that completed and a run that worked. The AI observability views in PRISM are built on exactly this data.

Step 1: Understand what a trace contains

A trace covers one complete agent run, from the first user message to the final response. Everything in between is recorded as a series of steps.

Each step is a span, a single unit of work. Common span types are:

  • Model call: the input sent to the LLM and the output returned, with latency and token counts.
  • Tool call: the tool name, the arguments, and the result.
  • Retrieval: the query, the retrieved documents and their scores.
  • Handoff: control passing from one agent to another in a multi-agent workflow, with the state carried across.
  • Error: what failed, at which step, and what state the agent was in when it did.

Spans nest. A model call might trigger a tool call, which triggers a retrieval. That nesting shows what happened at each level of the run.

At the trace level, you see the per-run request, response, model, cost, timing, scores, trajectory steps and any guardrail flags. At the run level, you see the full set of steps, tool calls, retrieval operations, retries, handoffs and state, and the point where a run failed.

Step 2: Choose how you will send traces

There are four instrumentation paths. You need exactly one.

Python SDK Attach a handler to your framework. The SDK records full trajectories: model calls, tool calls, retrieval, handoffs and errors, structured as nested spans.

Example · text
pip install "prismtrace-sdk>=0.5.1"

The SDK supports these frameworks directly:

FrameworkHandler
LangChainPRISMtraceCallbackHandler
LangGraphPRISMtraceLangGraphHandler / wrap_langgraph
Google ADKPRISMtraceADKAdapter (records multi-agent handoffs as handoff steps)
LiteLLMinstall_litellm
OpenAI Agents SDKinstall_openai_agents
Anthropic Python clientClaudeAgentTracer (wraps the Anthropic Messages API)

Note: ClaudeAgentTracer wraps the Anthropic Messages API. It is not a Claude Agent SDK integration.

Zero-code proxy Change the base URL in your client config to https://api.prism.blockconvey.com/proxy/openai/v1, /proxy/anthropic or /proxy/gemini. Nothing else changes. The proxy forwards the call, records it and runs your guardrails in both directions. Use this path when you want inline guardrails without importing anything.

OpenTelemetry Set two environment variables, the OTLP endpoint and your key header. No PRISM SDK required. The endpoint is https://api.prism.blockconvey.com/api/otlp; the exporter appends /v1/traces. Use http/protobuf or http/json protocol. gRPC is not served.

HTTP Send one POST /api/traces after each response. This is the right path for TypeScript, Go, Java or any framework the SDK doesn't cover. It has no dependencies beyond the ability to make an HTTP request.

All four paths reach the same API host: https://api.prism.blockconvey.com.

See the full list of supported connectors on the AI Agent and LLM Integrations page.

Step 3: Decide what fields to capture

Every trace sent to POST /api/traces needs five fields. Everything else is optional but useful.

Here are the five fields every trace requires, plus optional fields that unlock more analysis:

Required fields

FieldTypeNotes
project_idstringWhich project this trace belongs to
modelstringThe model name, e.g. "gpt-4o"
input_messagesarray of {role, content} objectsThe conversation history up to this exchange
output_messagestringThe agent's reply
latency_msintegerEnd-to-end latency; send 0 if not measured

Optional fields that unlock more analysis

FieldTypeWhat it enables
session_idstringGroups traces into one conversation (multi-turn journey and drift analysis)
agent_idstringPopulates the Model Inventory for that agent
agent_namestringHuman-readable label in the dashboard
user_identifierstringTies traces to a specific user
trace_idstringYour own ID for the trace, for cross-referencing
token_count_inputintegerInput token cost tracking
token_count_outputintegerOutput token cost tracking
metadataobjectAny key-value data you want to attach

A successful POST /api/traces returns 200 with the stored trace's id, cost_usd and session_id.

On session_id: traces that share a session_id are grouped into one conversation and displayed as a multi-turn journey. Sessions cannot be backfilled, if you start sending session_id on trace 50, traces 1 through 49 are not retroactively grouped.

On agent_id: the Model Inventory fills itself from the agent_id and model fields on your traces. It shows trace count, average latency, last activity and provider, with nothing to register by hand. If you omit agent_id, the inventory stays empty.

Step 4: Handle PII and sensitive content

By default, PRISM stores full prompt text and response text. For most teams that's the right choice, it's what makes traces debuggable. But if your use case involves regulated data, you have two options.

Content-free ingest

This is a project-level setting under Settings › Data handling. When it's on, prompt text, response text and error messages are dropped at ingest. PRISM keeps structure, timings, token counts, cost, model and outcome, enough to track latency, cost and failure rates, but nothing that could contain a customer's words.

Traces ingested this way are never sent to the LLM judge: they receive no automatic quality scores and no Evaluator scores, and are not billed for either. The deterministic guardrail rules still run. The setting applies to new traces only; existing traces are unaffected.

Key scoping

An application that only sends traces should use an ingest-scoped key. An ingest key cannot read data back or spend credits, so a compromised key causes minimal damage. Keys look like pt-sk-…, are shown once (PRISM stores only a hash), and can be rotated with a grace period before the old one is revoked. Store them in the environment or a secret manager, not in source code.

Voice

If you're tracing a voice agent, audio is never sent to or stored by PRISM. Transcripts are PII-scrubbed server-side before storage.

Once you've decided what to capture, you're ready to verify that data is arriving. See how to use evaluation metrics to put the traces you collect to work.

Step 5: Verify the pipeline is working

Sending a trace and not seeing it in the dashboard is a common first-hour problem. The pipeline has five stages, and a misconfiguration at any one of them will silently drop data.

The connection health tool walks the pipeline stage by stage:

  • Key created
  • Your code reached PRISM
  • First trace arrived
  • Trace readable
  • Analysis ready

It names the stage that is stuck, so you don't have to guess whether the problem is a bad key, a wrong host, a missing field or a network block.

You can also call the setup-doctor endpoint directly. It is a handshake: it proves a credential is valid and returns the pipeline state. Use it in a CI health check or a startup script to catch a broken configuration before it reaches production.

How this looks in production

Here is a minimal HTTP trace. It sends one exchange, a user message and the agent's reply, and records latency.

Example · text
POST https://api.prism.blockconvey.com/api/traces
X-PRISMtrace-Key: pt-sk-your-key-here
Content-Type: application/json

{
  "project_id": "proj_abc123",
  "model": "gpt-4o",
  "input_messages": [
    {"role": "user", "content": "What's my account balance?"}
  ],
  "output_message": "Your current balance is $1,240.00.",
  "latency_ms": 820,
  "session_id": "sess_xyz789",
  "agent_id": "banking-assistant-v2"
}

The call returns 200 with the trace's id, cost_usd and session_id.

What PRISM does on arrival, automatically and at no credit cost:

  • Scores the trace: customer satisfaction (0–100), response quality (0–100 covering accuracy, helpfulness and clarity), the intent detected, and a flagged-for-review mark with a one-line reason if either score is below 40, the reply looks like a hallucination, the user seems very frustrated, or the conversation contradicts itself.
  • Groups the trace into a session: because this trace carries a session_id, it is added to that conversation and the multi-turn view updates.
  • Assembles the trajectory: tool calls, retrieval steps and handoffs sent as spans are stitched together under this trace.
  • Runs guardrail checks: any active rules evaluate the trace immediately.

If your volume exceeds the plan's daily LLM-judge ceiling, automatic scoring pauses until 00:00 UTC, but the trace is still stored, and deterministic rules keep running. No traces are refused.

To see traces as a session, conversations and agent observability views, navigate to the PRISM dashboard after your first trace lands.

Send your first trace and watch automatic scores appear, start free.

Common mistakes

1. Sending input_messages as plain strings

The field is an array of objects, each with a role and a content key. Sending a plain string or an array of strings causes a validation error.

Example · text
// Wrong
"input_messages": ["What is my balance?"]

// Right
"input_messages": [{"role": "user", "content": "What is my balance?"}]

2. Omitting session_id on a multi-turn agent

Without a session_id, each trace is an isolated event. The Sessions view, which shows the multi-turn journey, drift over a conversation and patterns across repeated interactions, only works when traces share a session ID. Sessions cannot be backfilled. If you add session_id on day two, day one is never grouped.

3. Skipping agent_id

The Model Inventory fills itself from the agent_id and model fields on your traces. If you omit agent_id, the inventory for that agent never populates. You won't see trace counts, average latency or last-activity data per agent until you add it, and because backfill isn't possible for sessions, start sending it from your first trace.

4. Installing an SDK version below 0.5.1

The floor is 0.5.1. Older releases are missing features the platform now depends on. Use pip install "prismtrace-sdk>=0.5.1" and pin to a specific release when you're ready to lock your environment.

5. Pointing your key at the dashboard host

The API host is https://api.prism.blockconvey.com. All endpoints, /api, /proxy and /mcp, are served there. prism.blockconvey.com is the dashboard; requests sent there return an error. Also: use the X-PRISMtrace-Key header for API keys. Authorization: Bearer is rejected for a standard API key (it is accepted only on /mcp).

What is the difference between a trace and a span?

A trace is one complete agent run; a span is a single step inside it.

A trace covers the full run from the user's first message to the agent's final response. A span is a single unit of work within that run: one model call, one tool call, one retrieval operation, one handoff, one error.

Spans nest. A model call might trigger a tool call, which triggers a retrieval. That nesting shows what happened at each level of the run.

At the trace level you see the per-run request, response, model, cost, timing, scores, trajectory steps and guardrail flags. At the run level you see every step, tool call, retrieval, retry, handoff and state transition, plus the exact point where a run failed.

Is agent tracing the same as LLM tracing?

No. LLM tracing records a single model call; agent tracing records a full run that may include many model calls, tool invocations, retrieval steps, retries and handoffs between agents.

The goal of agent tracing isn't just to confirm that each call succeeded. It's to track whether the user's goal was met. A tool can return 200. The model can respond at every step. And the agent can still give the wrong answer, take the wrong action or loop indefinitely. Agent tracing, by recording the trajectory and tracking the outcome against the user's intent, surfaces that.

Does agent tracing slow down my agent?

It depends on the instrumentation path.

The zero-code proxy sits in the request path. It forwards the call to the provider, records it and runs guardrail checks in both directions. This adds one network hop, roughly 5 to 15 ms depending on region.

The HTTP path, the Python SDK and the OpenTelemetry path each send or flush trace data outside the user-facing response, so the tracing overhead does not affect the response the user receives.

Start tracing your agent today

One HTTP call instruments your agent. Automatic scoring, session grouping and trajectory assembly run from the first trace.

Free to start, 100 credits each month.