AI Development

How Do We Monitor and Audit an AI Agent in Production?

How to monitor and audit an AI agent in production: OpenTelemetry GenAI traces, what to log, tracing tools compared, evaluations, alerts and an audit trail.

Published November 28, 2026. Attribute and span names are from the OpenTelemetry GenAI semantic conventions, whose first standalone release, v0.1.0, was published on November 21, 2026; tool details are from each vendor's documentation, checked the same day.

Short answer. Trace every agent run as OpenTelemetry spans (the agent, each model call and each tool call), record tokens, cost, latency, errors and approvals on those spans, and alert on cost per task, error rate and how often cases are escalated. Run a fixed set of test cases before every change and score a sample of live runs. For regulated work, write a separate, append-only audit trail of who asked, what the agent did, to which record and who approved it. As of November 2026 the OpenTelemetry GenAI conventions are still marked Development, so pin the version you use.

Key facts at a glance

  • Standard for agent telemetryOpenTelemetry GenAI semantic conventions; standalone repository, v0.1.0 released November 21, 2026; status Development
  • Span namesinvoke_agent {agent}, chat {model}, execute_tool {tool}
  • Token attributesgen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.usage.cache_read.input_tokens
  • Content captureOff by default: OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT=NO_CONTENT
  • OpenAI EvalsRead-only; shuts down November 30, 2026, with Promptfoo named as the migration path
  • HIPAAAudit controls are required by 45 CFR 164.312(b); required documentation is kept 6 years under 164.316(b)(2)(i)

Monitoring, evaluation and audit: what is the difference?

Teams often buy one tool and expect it to do all three. They answer different questions, for different people:

ObservabilityEvaluationAudit trail
Question it answersWhat happened in this run, and why was it slow or expensive?Is the agent still right often enough?Who did what, to which record, with whose approval?
Who uses itDevelopers, on-callDevelopers, product ownerCompliance, auditors, managers
DataTraces, spans, metrics, sometimes promptsTest cases, scores, comparisons between versionsStructured events, no free text needed
RetentionDays to monthsKept per releaseYears, set by your policy or regulation
Who may change itEngineeringEngineeringNobody: append-only

What should you log for every agent run?

An AI agent run is a chain: the agent decides, calls a model, calls tools, maybe asks a person, and finishes. OpenTelemetry (OTel), the open standard for traces and metrics, now has agreed names for each link, so any tracing tool can read them.

One agent run, as a trace

Each line is a span, in time order. Tokens and cost ride on the model spans.

  1. 1invoke_agent · invoice-agent: the whole run8.4 s, $0.021
  2. 2chat · gpt-6.2-sol6.1k tokens
  3. 3execute_tool · read_document (OCR)tool
  4. 4chat · gpt-6.2-sol8.4k tokens
  5. 5execute_tool · match_vendortool
  6. 6chat · gpt-6.2-sol9.2k tokens
  7. 7approval · review queuesent
Figure 1. A single agent run as an OpenTelemetry trace: agent, model and tool spans in time order (illustrative values). Span names per OpenTelemetry GenAI conventions v0.1.0.
What to recordOpenTelemetry attribute or spanWhy
The run as a wholeinvoke_agent {agent} span; gen_ai.agent.name, gen_ai.conversation.idOne place to see the whole task
Each model callchat {model} span; gen_ai.provider.name, gen_ai.request.modelWhich model did what, and how long it took
Tokensgen_ai.usage.input_tokens, output_tokens, cache_read.input_tokensCost per task and cache health
Each tool callexecute_tool {tool} span; gen_ai.tool.name, gen_ai.tool.call.idFind loops, slow systems and failing tools
Why the model stoppedgen_ai.response.finish_reasonsSpot truncation and refusals
Errorserror.type and span statusError rate per tool and model
Business outcomeYour own attributes, such as app.outcome and app.escalation_reasonEscalation rate is the best early warning
VersionYour own app.agent_version and prompt versionTie a drop in quality to a release

Instrumentation libraries exist for the main providers and frameworks, but a few lines of manual spans show what they record:

from opentelemetry import trace
from opentelemetry.trace import SpanKind

tracer = trace.get_tracer("invoice-agent")

def run_agent(task):
    with tracer.start_as_current_span("invoke_agent invoice-agent", kind=SpanKind.INTERNAL) as agent:
        agent.set_attribute("gen_ai.operation.name", "invoke_agent")
        agent.set_attribute("gen_ai.agent.name", "invoice-agent")
        agent.set_attribute("gen_ai.conversation.id", task.id)

        with tracer.start_as_current_span("chat gpt-6.2-sol", kind=SpanKind.CLIENT) as span:
            resp = client.responses.create(model="gpt-6.2-sol", input=task.items, tools=TOOLS)
            span.set_attribute("gen_ai.operation.name", "chat")
            span.set_attribute("gen_ai.provider.name", "openai")
            span.set_attribute("gen_ai.request.model", "gpt-6.2-sol")
            span.set_attribute("gen_ai.usage.input_tokens", resp.usage.input_tokens)
            span.set_attribute("gen_ai.usage.output_tokens", resp.usage.output_tokens)
            span.set_attribute("gen_ai.usage.cache_read.input_tokens",
                               resp.usage.input_tokens_details.cached_tokens)

        for call in tool_calls(resp):
            with tracer.start_as_current_span(f"execute_tool {call.name}", kind=SpanKind.INTERNAL) as t:
                t.set_attribute("gen_ai.operation.name", "execute_tool")
                t.set_attribute("gen_ai.tool.name", call.name)
                t.set_attribute("gen_ai.tool.call.id", call.call_id)
                run_tool(call)

Then point the exporter at your tracing tool. Message content is the sensitive part, and the conventions keep it out unless you opt in:

# Export to any OTLP endpoint. Langfuse Cloud (US) shown; LangSmith uses https://api.smith.langchain.com/otel
OTEL_EXPORTER_OTLP_ENDPOINT=https://us.cloud.langfuse.com/api/public/otel
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <base64 of public_key:secret_key>
OTEL_SERVICE_NAME=invoice-agent

# Prompts and completions stay out of traces unless you opt in
OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT=NO_CONTENT

The other accepted values are SPAN_ONLY, EVENT_ONLY and SPAN_AND_EVENT. Turn content on only in environments where the data is allowed to sit in your tracing tool, and never for patient or card data without redaction.

How do you trace an agent that calls MCP servers or other agents?

A trace is only useful if it does not stop at the edge of your process. When your agent calls an MCP server, another agent or an internal API, the downstream work should appear as child spans of the same trace, so one view shows the whole task.

Over plain HTTP, OpenTelemetry does this with the W3C traceparent header. MCP is different: many messages can travel inside one connection, so the HTTP header is not enough. The OpenTelemetry MCP conventions say instrumentations SHOULD inject the trace context into each request's params._meta field, using the unprefixed keys traceparent, tracestate and baggage, and the server SHOULD use it as the remote parent:

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "match_vendor",
    "arguments": {"vendor_name": "Acme Supplies Pty Ltd"},
    "_meta": {"traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}
  },
  "id": 7
}

MCP client and server spans are named {mcp.method.name} {target}, for example tools/call match_vendor, with span kinds CLIENT and SERVER. If you run the MCP server yourself, add the same propagation on its side; if it is a vendor's server, you will at least see the client span and its duration. For agents that hand work to other agents, propagate the same context through whatever queue or API connects them, and give every agent a distinct gen_ai.agent.name so the trace reads like an org chart of who did what.

Which tracing tool should you use?

Because all of these accept OpenTelemetry, the choice is less permanent than it looks: instrument once with OTel and you can change the destination later.

ToolHow it takes OTel dataGood fitCheck
LangfuseOTLP endpoint at /api/public/otel (EU, US and other regions); maps gen_ai.* attributesTeams wanting self-hosting or a cloud option, prompt management and evaluationsRegion and data residency; self-hosting effort
LangSmithOTLP endpoint at /otel on your LangSmith API URL; maps gen_ai.* attributesTeams on LangChain or LangGraphOlder attribute spellings are accepted but deprecated
Arize PhoenixBuilt on OpenTelemetry and OpenInference instrumentationOpen-source tracing and evaluation you can run yourselfHosting and scaling if self-run
Microsoft Foundry tracingOpenTelemetry into Azure Monitor Application Insights; off until you connect a resourceAgents on Azure and Foundry Agent ServiceApplication Insights data volume and retention costs

How do you evaluate an agent continuously?

Monitoring tells you the agent ran. Evaluation tells you it was right. Three habits cover most of it:

  1. A fixed test set. Collect 50 to 200 real cases with the correct outcome, including the awkward ones: wrong totals, duplicate invoices, ambiguous requests, injected instructions. Run them before every prompt, model or tool change and block the release if the score drops.
  2. Scored samples of live runs. Each week, score a random sample of production runs, by people or by a model acting as a judge with a written rubric. Track the score per agent version.
  3. Every escalation is a test case. When the agent hands a case to a person, or a person corrects it, add it to the test set.

If your evaluations live in OpenAI's Evals product, move them now: the deprecations page lists the Evals dashboard, API and graders as read-only, shutting down on November 30, 2026, and names Promptfoo as the migration path.

What should trigger an alert?

SignalExample threshold (estimate)Usually means
Cost per taskMore than 2 times the 7-day medianA loop, a cache miss or a bloated tool result
Escalation rateUp 50% on the 7-day averageInput changed, a system changed, or quality dropped
Tool error rateOver 2% for 15 minutesA connected system is down or its API changed
Steps per taskAny task at the step capThe agent is stuck
Latency p95Over your user-facing targetProvider slowdown, oversized context
Refusals or truncationsAny sustained rise in finish_reasons other than normal stopsPrompt or model behavior changed

The thresholds are starting points; set yours from two weeks of normal traffic.

What does an audit trail need for regulated work?

Debug traces are not an audit trail. They are sampled, editable, kept briefly and may contain text you should not keep. An audit trail is a separate stream of structured events that answers who, what, which record, when and with whose approval. Under HIPAA, the Security Rule requires "audit controls", mechanisms "that record and examine activity in information systems that contain or use electronic protected health information" (45 CFR 164.312(b)). HIPAA does not set a log retention period itself, but required documentation must be kept 6 years (164.316(b)(2)(i)), which many organizations apply to audit logs by policy.

Three streams, three stores

Debug traces, live metrics and the audit trail have different owners and retention.

Agent with OpenTelemetry SDKspans, metrics, audit events

Collectorredacts content, routes each stream

TracesLangfuse, LangSmith, Phoenix or App Insights; 30 to 90 days
Metricscost, errors, latency, feeding alerts
Audit trailappend-only; years, per policy
Figure 2. Keep debugging traces, live metrics and the audit trail in separate stores. Retention periods are examples; set them by policy.

One event per consequential action is enough:

{
  "event": "agent.action",
  "time": "2026-11-28T10:14:03Z",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "agent": "invoice-agent",
  "agent_version": "2026.11.3",
  "model": "gpt-6.2-sol",
  "requested_by": "ap.clerk@company.example",
  "tool": "erp.post_invoice",
  "record": "AP-INV-88213",
  "inputs_hash": "sha256:9f1c...",
  "decision": "sent_to_review",
  "reason": "total does not match purchase order PO-4471",
  "approved_by": null
}
  • Append-only storage. Use write-once storage such as S3 Object Lock or Azure immutable blob storage, in an account the agent cannot delete from.
  • Hashes, not payloads. Store a hash of the inputs and the record ID, so you can prove what was processed without copying sensitive text into another system.
  • The trace ID links the two. An auditor sees the event; an engineer with access can open the matching trace while it is retained.
  • Versions on every event. Agent version, prompt version and model, so a decision can be tied to the exact configuration that made it.

Our invoice agent sends each exception to a review queue with its reason, and our Teams helpdesk agent cites the policy behind each answer. Both are the same idea: every decision carries its own explanation.

What this means for owners

  • Ask for three numbers every month: cost per task, escalation rate and the latest test-set score.
  • Make sure an audit trail exists separately from the developers' tracing tool, and who can read it.
  • Agree retention periods for traces and audit events with your compliance lead.
  • Treat a rising escalation rate as a quality problem, even when nobody has complained.

What this means for developers

  • Instrument with OpenTelemetry GenAI names and pin the semconv version; it is still Development.
  • Keep OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT=NO_CONTENT by default; redact in the collector.
  • Gate releases on a fixed test set; add every escalation to it.
  • Write audit events to write-once storage with trace IDs, versions and input hashes.

Frequently asked questions

What is AI agent observability?

It is the ability to see what an agent did on each run: which model calls and tool calls it made, in what order, how long they took, how many tokens they used and where it failed. In practice it means tracing every run as OpenTelemetry spans and tracking cost, errors and escalations as metrics.

What is the OpenTelemetry standard for AI agents?

The OpenTelemetry GenAI semantic conventions. They define span names such as invoke_agent, chat and execute_tool and attributes such as gen_ai.request.model and gen_ai.usage.input_tokens. The first standalone release, v0.1.0, was published on November 21, 2026, and the conventions are still marked Development.

Should we log prompts and responses?

Not by default. The conventions keep message content out unless you opt in through OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT. Capture content only where the data may legally sit in your tracing tool, with redaction for personal, health or payment data.

What is the difference between monitoring and evaluating an AI agent?

Monitoring shows what happened and how fast and costly it was. Evaluation measures whether the agent was right, using a fixed set of test cases before each change and scored samples of live runs.

How long should we keep AI agent audit logs?

Set it by policy and regulation. HIPAA requires audit controls but no specific log period; required documentation must be kept six years, and many organizations apply that to audit logs. Debug traces are usually kept far shorter.

Which AI agent tracing tool is best?

It depends on your stack. Langfuse suits teams wanting self-hosting or cloud with prompt management, LangSmith suits LangChain and LangGraph teams, Arize Phoenix is open-source and OpenTelemetry-based, and Microsoft Foundry tracing fits agents on Azure. All accept OpenTelemetry, so instrument once and choose later.

What should we use instead of OpenAI Evals?

OpenAI lists the Evals dashboard, API and graders as read-only with shutdown on November 30, 2026, and names Promptfoo as the migration path. Tracing tools such as Langfuse, LangSmith and Phoenix also run evaluations.

Running an agent you cannot see inside? We add OpenTelemetry tracing, cost and escalation metrics, release-gating test sets and an append-only audit trail to agents in production, and keep them running under our support and maintenance service. Building a new one? See our AI agent development service.

Get a free project estimate →

Nikit Nandan photo
Nikit Nandan

Strategy Director

Nikit is experienced in conducting in-depth research to stay abreast of industry trends and emerging technologies.

Let’s build your idea!

Let us help you with a free analysis and estimate. Our product expert will contact you within one business day.

 All your information is kept confidential and protected by NDA.
;