AI security

AI observability: how to monitor AI agents in production without logging what you need to protect

AI observability is the practice of recording what an AI system did, step by step, so someone can explain any result after the fact: which model was called, which tools ran, how long each step took, what it cost, and whether the output reached the place it was meant to go. For AI agents that read company data and take actions, it is also a security control. When something goes wrong, the trace is how you tell a bug from a bad answer from an attack.

We run AI agents in our own operations, and we instrumented them before we let them do anything that mattered. This guide covers the approach we took, the part most teams get wrong (what the telemetry is allowed to contain), and how a working trace pipeline changes an AI security investigation.

What is AI observability?

Traditional monitoring answers "is it up?" A web server is healthy, or it isn't. An AI agent can be up, fast, and error-free while still doing the wrong thing. It might call the wrong tool, retry a step six times, burn through tokens, or send a reply that nobody received. Observability is what lets you see those failures.

In practice, AI observability for an agent means three kinds of record:

  • Traces. One trace per agent turn, with a span for each model call and each tool action inside it. This is the backbone.
  • Metrics. Latency, error rates, token counts, and cost, rolled up so you can spot drift and plan capacity.
  • Outcome records. Whether the job ran, and separately whether its result was delivered and accepted by the destination system.

Evaluations are related but different. An evaluation asks whether an answer was good. Observability asks what happened. You need the second before the first is worth much, because you can't judge an output you can't trace back to its inputs and actions.

Why AI observability is a security control

Most writing on this topic treats observability as an engineering convenience: faster debugging, better dashboards. That's true, but it undersells it. Once an agent has permissions, its activity log is an audit trail, and an audit trail is a security control.

The OWASP guidance on excessive agency describes the core risk well. An agent with more functionality, permissions, or autonomy than it needs can be steered into harmful actions, often through prompt injection. Least privilege and approval steps reduce that risk. Observability is how you find out whether those controls held, and what the agent actually did when they didn't.

Without traces, an AI incident review is guesswork. With them, you can answer the questions an executive, a customer, or an insurer will ask: what did the agent touch, when, on whose behalf, and what left the building?

How we set up AI agent observability

Our setup is built on OpenTelemetry, the open standard for traces and metrics, feeding a self-hosted trace store. Arize Phoenix and Langfuse are both common choices for that store. The tool matters less than the decisions below.

1. Trace the whole agent turn, not just the model call

Many teams start by logging LLM requests and stop there. The model call is rarely where the interesting failure is. We create one parent span for each agent turn, with child spans for every model call and every tool action. Model spans carry latency, a bounded error category, and token counts when the provider reports them. Tool spans carry duration and outcome. Tool names come from an approved list, so an unexpected tool name shows up as an anomaly instead of blending in.

2. Decide what the telemetry is allowed to contain

This is the step most deployments skip, and it's the one a security leader should care about most. Prompts, model responses, attachments, and tool payloads routinely contain customer data, credentials, and internal documents. If all of it lands in your trace store, you've built a second copy of your most sensitive data, usually with weaker access controls than the original.

Our exporter works from an allowlist. It sends approved operational metadata and nothing else. Prompts, responses, attachments, tool payloads, and raw error messages are excluded by default. (Raw errors are on that list because they often echo input back.) The OpenTelemetry guidance on handling sensitive data makes the same point: decide what's collected at the source rather than trying to scrub it later.

3. Send traces to a store you control

Trace ingestion is authenticated and dashboard access is restricted to the people who need it. Each agent runtime reports into its own project, so one runtime's data can't get mixed up with another's and access can be granted per runtime. Treat the trace store like any other system holding operational records. It belongs in your access reviews and your vendor risk process if someone else hosts it.

4. Prove the pipeline works before you trust it

A dashboard with no data looks the same as a dashboard where nothing went wrong. Before relying on the pipeline, we sent a synthetic test request through each runtime and confirmed the expected turn, model, and tool spans arrived in the trace store. We started with a single agent, verified it end to end, and only then added more. Each new runtime gets the same check before it goes live.

5. Watch execution and delivery as separate things

This one surprised us. "The job ran" and "the result arrived" are different facts, and they fail independently. A scheduled job can fail halfway and still deliver a partial reply. Another can complete perfectly and then fail to deliver because the destination rejected it. We record execution and delivery separately. A successful delivery means the destination system accepted the message. That is the fact you want during an investigation.

6. Alert when the data goes quiet

Every runtime emits a reporting heartbeat. If the data stops arriving, that opens an investigation. Silence is the failure mode that hides everything else: an exporter that crashed, an expired credential, a misconfigured collector. Failed scheduled jobs page through the same cloud alerting we use for the rest of our infrastructure, so AI problems land in the existing on-call path instead of a separate inbox.

What to capture and what to keep out

If you take one thing from this guide, make it this table. It's the conversation to have with whoever is building your agents before they pick a tool.

Capture by defaultKeep out of telemetryWhy
Turn, model, and tool spans with timingFull prompts and model responsesStructure explains behavior; content is where sensitive data lives
Tool names from an approved listTool arguments and payloadsYou need to know a tool ran, not the record it touched
Bounded error categoriesRaw error messages and stack tracesRaw errors often echo user input or secrets
Token counts and costAttachments and retrieved documentsCost tracking needs counts, not the documents themselves
Execution status and delivery statusMessage bodies sent to customersThe destination system already holds the content under its own controls
Runtime, environment, and versionUser credentials, tokens, and API keysNever collected, under any circumstances

How AI observability helps in a security investigation

Here's how it plays out. Say a customer reports that your support agent sent them another customer's order details. Without observability, you have a complaint and an agent that seems fine. With it, the investigation has a path:

  1. Find the turn. Delivery records show the reply the customer received and when. That leads to the trace for that agent turn.
  2. Read the shape of the trace. Which tools ran, in what order, and how many times? A lookup tool called with an unusual pattern or an unexpected tool name is a strong lead.
  3. Match against the destination's audit log. Trace timestamps line up with the audit logs in your CRM or email system, which show what was actually read and sent.
  4. Examine the input where it lives. If injection is suspected, the original message is reviewed in the source system under that system's access controls, not pulled into a shared dashboard.
  5. Decide and contain. Bug, bad retrieval, or attack. The answer determines whether you patch, retrain, revoke a permission, or invoke your incident response plan.

Notice that the trace store never needed the sensitive content. Structure and timestamps point to the right records, and the content stays in systems that were already built to protect it.

What observability won't do

Observability is detective, not preventive. It tells you what happened. It won't stop an agent from doing something it's allowed to do. The controls that limit damage are still least-privilege permissions, human approval for consequential actions such as payments, deletions, and external email, and a fast way to revoke an agent's access. Observability is how you check those controls are working, and how you recover when one fails.

It also doesn't replace evaluation. A trace can show that an agent answered in two seconds using the right tools. It can't tell you whether the answer was right.

How to start monitoring AI agents in production

You don't need a platform project to get started. For a business running its first few agents, this order works:

  1. Inventory your agents. List every agent or automation that calls a model, what it can access, and who owns it. Our AI acceptable use policy template includes a register for this.
  2. Write the telemetry allowlist first. Agree on what may and may not be collected before any tool gets installed.
  3. Instrument one agent end to end. Turn, model, and tool spans, sent to a store with authenticated ingestion and restricted access.
  4. Verify with a synthetic request. Confirm the expected spans arrive, then add a heartbeat so silence raises an alert.
  5. Separate execution from delivery. Record both, and route failures into the alerting your team already watches.
  6. Expand one runtime at a time. Each new agent gets the same verification before it goes live.

The goal is not a beautiful dashboard. The goal is that the next time someone asks what your AI did, you can answer with evidence.

Common questions

What is AI observability?

AI observability is the practice of recording what an AI system did, step by step, so a person can explain any result after the fact. For an AI agent that means a trace for each turn with spans for every model call and tool action, plus metrics such as latency, errors, token counts, and cost, and records of whether each result was delivered.

What is the difference between AI observability and AI monitoring?

Monitoring tells you whether a system is up and within thresholds. Observability tells you why it behaved the way it did. An AI agent can be up and error-free while calling the wrong tool, retrying a step repeatedly, or sending a reply nobody received. Traces are what make those failures visible.

Should prompts and responses be stored in AI observability tools?

Not by default. Prompts, responses, attachments, tool payloads, and raw error messages often contain customer data, credentials, or internal documents. Collecting them builds a second copy of sensitive data, often with weaker access controls. A safer pattern is an allowlist that exports only operational metadata and leaves content in the source systems, where it can be reviewed under their own access controls during an investigation.

How does AI observability improve AI security?

It provides the audit trail for agent activity. When an agent has permissions, traces show which tools it used, in what order, and when. Matched against the audit logs of the systems the agent touched, that evidence lets a team tell a bug from a bad answer from an attack such as prompt injection, and confirm whether least-privilege and approval controls held.

What tools are used for AI agent observability?

OpenTelemetry is the common open standard for collecting traces and metrics from AI agents. Teams send that data to a trace store such as Arize Phoenix or Langfuse, either self-hosted or as a managed service, or to an existing observability platform. The more important decisions are what the telemetry may contain, who can access it, and how the pipeline is verified.

Does AI observability prevent AI attacks?

No. Observability is a detective control. It shows what happened but does not stop an agent from taking an action it is permitted to take. Prevention still depends on least-privilege permissions, human approval for consequential actions, and the ability to revoke an agent's access quickly. Observability is how you verify those controls work.

Talk it through with an operator

If security leadership is becoming a business question for your company, a security conversation is the fastest way to see whether fractional leadership fits.

Request a security call