Observability & Tracing
A guest complains about something your agent said last Tuesday. Can you open that exact conversation and see what the agent was shown, what it decided, which rules fired and which prompt version was running? If the answer is "not really", this topic is for you.
Definition: Observability and tracing for AI agents is the practice of recording every step an agent takes (each model call, tool call, guardrail decision and human approval, with its inputs, outputs, timing, cost and versions) so any run can be inspected, replayed, audited and improved.
1 The big idea
You cannot fix what you cannot see
Normal software usually fails loudly: an error, a crash, a red line in a log. Agents often fail quietly. The reply is polite and well written, but based on an old policy. The price is reasonable, but the agent skipped a check to get there. The task finished, but took ten model calls instead of three. Nothing crashed, so nothing was logged.
Observability means being able to answer questions about what your system did, including questions you did not think of in advance. For agents, the main tool is the trace: a step-by-step record of one task, from the request coming in to the final reply. Each step inside it is a span, with a start time, an end time and the details of what happened.
With good traces, "the agent said something odd last week" becomes a five-minute investigation instead of a guess. Without them, every incident ends with the same sentence: "We are not sure what happened."
Think of a flight recorder. Aircraft record what the instruments showed, what the crew did and what the plane did, second by second. Nobody plans to need it. But when something goes wrong, it turns "what happened?" from an argument into a reading. A trace is your agent's flight recorder, except you will read it far more often.
2 Interactive map
The nine parts of agent observability
Click any part to see what it does, an example, and what goes wrong without it.
Click or tab to any part
Traces and spans
One trace per task, with one span for each step inside it: model calls, tool calls, guardrail checks, human approvals. Spans nest and are timed, so you can see the order and where the time went.
Read all 9 parts as text
- Traces and spans
- One trace per task, with one span for each step inside it: model calls, tool calls, guardrail checks, human approvals. Spans nest and are timed, so you can see the order and where the time went. Example: Trace T-77310 for a refund request: build context (0.2s), model call (1.8s), permission check (0.01s), lookup_payments (0.6s), model call (1.4s), refund (0.9s), verify (0.4s), reply. Without it: You have scattered log lines from different systems and no reliable way to stitch one task back together.
- Inputs and context
- Record what the model was actually shown before each decision: which documents, which version of each, which past messages and which tool results. Store references and short extracts where the full text is large or sensitive. Example: The trace shows the model was given house_rules v10, not v11, because of a stale cache. That one line explains the bad answer. Without it: You can see the bad reply but not why the model gave it, so you end up rewording the prompt and hoping.
- Proposals and decisions
- Record what the model proposed, what the harness allowed or blocked and which rule decided, and who approved what. Keep the proposal and the final action separate. Example: Model proposed refund AED 4,200. Rule refund_limit blocked it. Support lead approved AED 1,500. The refund issued was AED 1,500. Without it: When someone asks "did the AI decide this or did a person?", nobody can answer with certainty.
- Version tags
- Tag every trace with the exact versions that ran: prompt, model, tool definitions, rules, and key documents. Changes are then easy to line up with changes in behaviour. Example: Complaints about tone start on 12 November. Filtering traces by version shows they all ran prompt support-v24, released that morning. Without it: "Which prompt was live last Thursday?" becomes an archaeology project through chat messages and commits.
- Tokens, cost and latency
- Record tokens used, estimated cost and time taken for every model call and tool call, and add them up per task, per agent and per customer journey. Example: A sales-lead task normally uses about 8,000 tokens. Since yesterday it uses 60,000. The spans show one tool now returns a whole web page instead of a summary. Without it: You learn about cost problems from the monthly bill, and about slow replies from customers.
- Privacy and redaction
- Remove or mask personal data such as card numbers, passport numbers, phone numbers and email addresses before traces are stored. Limit who can view traces and how long they are kept. Example: A guest sends a photo of their passport for check-in. The trace keeps "passport image received, verified" and a reference, not the image or the number. Without it: Your debugging tool quietly becomes the largest store of personal data in the company, readable by every engineer.
- Dashboards and alerts
- Turn trace data into a few numbers you watch and alert on: error rate, escalation rate, blocked actions, cost per task, and slow replies. Alerts link straight to example traces. Example: An alert fires at 10:40: cost per task for the sales-lead agent is three times its usual level. The alert links to the ten most expensive traces of the morning. Without it: Problems are found by customers, finance or chance, usually days later.
- Replay and evals
- Re-run a recorded trace against a new version, using the saved inputs and tool results, to check a fix. Good traces of real problems become permanent eval cases. Example: After fixing the stale cache, the team replays the complaint trace against the new version. The agent now quotes v11 correctly, and the trace joins the golden dataset. Without it: Fixes are checked by trying something similar by hand and hoping it is the same situation.
- Open standards (OpenTelemetry)
- OpenTelemetry is an open, vendor-neutral standard for traces, metrics and logs. It is adding conventions for AI work, such as names for the model used and token counts. These GenAI conventions are still evolving. Example: Agent spans are sent in OpenTelemetry format, so they appear in the same tracing tool as the booking system and payment API, in one timeline. Without it: Agent traces live in a separate tool with their own format, and you cannot follow one guest request from your website through the agent to the payment system.
Notice how many parts link to other topics in this series. A trace is where everything else becomes visible: the context, the tools, the guardrails, the human decisions and the evals.
3 Step-by-step simulator
Watch three investigations, from first signal to fix
Agents at a holiday-rental company: a guest-support agent and a sales-lead agent. Each scenario starts with a problem someone notices. Watch how the trace turns it from a mystery into a fix.
- Signalalert or person
- Find the traceengineer
- Read spanstrace
- Check versionstrace
- Find the causeengineer
- Fix and replayteam
- Preventteam
Guest complaint
A guest complains a week after their stay. The support team needs to know: did the agent really promise that, and why?
Read the walkthrough as text
Guest complaint
A guest complains a week after their stay. The support team needs to know: did the agent really promise that, and why?
- A complaint arrives a week later. The guest is upset and has a screenshot. The support lead wants to know whether this is a one-off or a pattern before replying.
- Find the trace by booking number. Traces are searchable by booking number, guest ID and date, not just by an internal trace ID. The conversation on 5 November comes up straight away. Why it matters: If you can only find traces by an ID nobody knows, you will not find them when it matters.
- Read the spans in order. The spans show the guest asked about late check-out. The context span lists the documents the model was given. The model replied "late check-out until 14:00 is free". No tool was called, so nothing was booked with housekeeping.
- Check the versions. The trace is tagged with house_rules v10. But v11 was published on 1 November. It says late check-out must be confirmed by housekeeping first. The agent was quoting last month's rules.
- Find the cause, and the size. A cache kept serving the old document. Searching all traces for house_rules v10 after 1 November finds 37 conversations. Six of them mention late check-out. Why it matters: Traces let you go from one complaint to every affected customer, so you can contact them before they complain.
- Fix it and replay the exact case. The cache now refreshes on every publish. The team replays the original trace against the fixed version: the agent now says late check-out depends on housekeeping and offers to ask.
- Prevent it coming back. The trace becomes an eval case. A new alert fires if any trace uses a document version that is no longer the live one. The guest gets an apology and a goodwill gesture approved by the support lead.
Cost spike
The sales-lead agent researches inbound enquiries before qualifying them. One morning, a cost alert fires. Without per-span cost tracking, this would show up at the end of the month.
- The alert fires. By 10:40, the average cost per task for the sales-lead agent is three times its usual level. The alert compares against the same hours on recent days and links to example traces.
- Open the most expensive traces. The engineer sorts this morning's traces by cost and opens the top one.
- Find the heavy span. Token counts per span show the problem at once. The model calls are normal size, except the one right after enrich_company. That tool used to return a short summary. Now it returns the whole web page, which is pasted into the context.
- Line it up with versions. Every expensive trace has tool version enrich_company 2.3. Version 2.3 was deployed yesterday evening by another team.
- The cause. Version 2.3 changed the output format and dropped the summary step. Nothing failed: replies were still fine, just far more expensive. That is why only a cost alert could catch it.
- Roll back and cap. The tool is rolled back to 2.2. The harness now cuts any tool result above a size limit and records that it did so.
- Prevent it. A per-task cost budget now stops any single task that goes far over normal and flags it. Tool releases now run the agent's eval suite too, including a cost check.
Slow replies
Guests on web chat are waiting a long time for answers. The model seems the obvious suspect. The trace timeline points somewhere else.
- Replies are slow. The alert watches the 95th percentile: the time within which 95% of replies arrive. It has jumped from about 8 seconds to 41. Averages can hide this kind of problem, because most replies are still fast.
- Open a slow trace. The engineer filters for replies over 30 seconds and opens one. The trace shows a timeline, with each span as a bar.
- The timeline tells the story. Both model calls take under two seconds. The check_availability tool call takes 34 seconds: it timed out twice at ten seconds, then succeeded on the third try.
- Check versions. No change to the prompt, model or tools in the last week. Whatever changed is outside the agent.
- Follow the trace downstream. Because the availability system also uses OpenTelemetry, the trace continues into it. Its database query became slow after a large import of new listings this morning. Why it matters: A shared tracing standard lets one trace cross from the agent into the systems it calls.
- Fix both sides. The availability team adds the missing index. The agent team shortens the timeout, allows one retry instead of two, and tells the guest "checking availability" while it waits.
- Prevent it. A new alert watches each tool's response time on its own, so next time the slow tool is named in the alert itself.
The point: in all three cases nothing crashed. The agent kept working, just wrongly, expensively or slowly. Only a trace with context, versions, tokens and timings on every step turned each of them into a quick fix.
4 Logs versus traces
Why plain logs are not enough for agents
Plain logs
- Separate lines from separate systems
- Hard to tell which lines belong to one task
- Usually record errors, not decisions
- Rarely say which prompt or model ran
- Often full of personal data by accident
Agent traces
- One record per task, with every step in order
- Each span timed, so slow steps stand out
- What the model saw, proposed and was allowed to do
- Tagged with prompt, model, tool and rule versions
- Tokens and cost per step
- Redacted before storage
- Searchable by booking, guest or lead
- Replayable as eval cases
You still need logs for the rest of your systems. The point of tracing is to connect everything that happened for one task into a single story you can read.
5 Build your own observability
Turn on observability parts. Watch the mysteries disappear.
These are the questions teams cannot answer during an incident. Tick the parts you have today and see which questions become easy. Many teams start with the agent's final replies in a database and nothing else.
- Cannot reproduce a guest complaint from last weekOnly the final reply was kept.
- Nobody knows which prompt version was live last ThursdayVersions were never recorded.
- Card and passport numbers are sitting in the logsEverything is stored as it arrived.
- Costs tripled overnight and finance found it at month endNobody tracks cost per task.
- Replies are slow and nobody knows which step is to blameNo timing per step.
- The run for booking #7741 cannot be found among millionsOnly internal IDs are searchable.
- The agent quoted an old policy, but the log only shows the replyIts inputs were not recorded.
- A fix was shipped with no proof it solves the original caseNothing to re-run.
- Problems are found by customers, days laterNobody is watching.
Read which part prevents which failure
- Cannot reproduce a guest complaint from last week: prevented by Step-level spans or Replay.
- Nobody knows which prompt version was live last Thursday: prevented by Version tags.
- Card and passport numbers are sitting in the logs: prevented by Redaction.
- Costs tripled overnight and finance found it at month end: prevented by Tokens and cost or Alerts.
- Replies are slow and nobody knows which step is to blame: prevented by Step-level spans.
- The run for booking #7741 cannot be found among millions: prevented by Business search.
- The agent quoted an old policy, but the log only shows the reply: prevented by Context captured.
- A fix was shipped with no proof it solves the original case: prevented by Replay.
- Problems are found by customers, days later: prevented by Alerts.
Redaction is the odd one out: it does not help you debug, it keeps your traces from becoming a liability. Add it from day one, because removing personal data from old traces later is much harder.
6 Optional: what it looks like in code
Tracing an agent loop in 21 lines
You don't need to read code to follow this. If you do, here is a traced agent loop. Each with tracer.span(...) block becomes one bar on the trace timeline. The highlighted line is the one people forget until it is too late.
def handle(task):
with tracer.span("task", booking=task.booking_id, guest=task.guest_id) as root:
root.tag(prompt="support-v24", model=MODEL_ID, # which versions ran
tools=TOOLS_VERSION, rules=RULES_VERSION)
context = build_context(task)
root.event("context", docs=context.doc_versions) # what it was shown
while not task.done and task.steps < MAX_STEPS: # step limit, as always
with tracer.span("model.call") as s:
action = model.next_action(context)
s.set(input_tokens=action.usage.input, output_tokens=action.usage.output,
cost=price(action.usage), proposal=action.summary)
with tracer.span("guardrail") as s:
verdict = allowed(action)
s.set(rule=verdict.rule, result=verdict.result)
if not verdict.ok:
context.add(verdict.message)
continue
with tracer.span("tool." + action.name) as s:
result = run_tool(action, timeout=10)
s.set(args=redact(action.args), status=result.status)
context.add(result)
7 The rules I build by
Eight principles of agent observability
Trace every step, not just the answer
Model calls, tool calls, guardrail checks and human approvals each get a span. The final reply is the least useful thing to record on its own.
Record what the model saw
Most odd answers come from odd inputs. Keep which documents and which versions went into the context, by reference where they are large or sensitive.
Tag every trace with versions
Prompt, model, tools, rules and key documents. When behaviour changes, the first question is always "what else changed?"
Count tokens, cost and time per step
Totals tell you there is a problem. Per-span numbers tell you where it is.
Redact before you store
Strip card numbers, passport numbers and contact details before traces are written. Limit who can read traces, and delete them on a schedule.
Make traces findable by business IDs
People report problems with a booking number, a guest name or a date. If those are not searchable, your traces will sit unread.
Alert on what customers feel
Escalation rate, blocked actions, slow replies and cost per task. Link every alert to example traces so the first click is already the investigation.
Close the loop: trace, eval, improve
This is where the whole series meets. Context, tools, guardrails, memory, human approvals and loops all show up in the trace. The trace feeds your evals, your evals guard every change, and every change is traced again. That cycle is how an agent keeps getting better after launch.
8 Common mistakes
Things teams say before a long incident
"We log every reply, so we're covered."
The reply is the end of the story. When it is wrong, you need the middle: what the model was shown, what it proposed, which rules fired and what each tool returned. Trace the steps, not just the output.
"Let's just log everything, we can clean it up later."
Logging raw conversations means storing card numbers, passports and phone numbers in a tool many people can read. Redact before storing, restrict access and set a retention period. Cleaning old traces afterwards is slow and easy to get wrong.
"We'll know which prompt was live from the commit history."
Maybe, after an hour of detective work, if nobody changed it in a dashboard. Tag every trace with the versions that actually ran. It costs a few fields and saves hours in every incident.
"We check the AI bill every month."
A month is a long time for a runaway loop or a tool that suddenly returns huge results. Track cost per task, compare it to a recent baseline and alert within hours.
"We have traces, we just never look at them."
Traces only help if someone reads them. Make them searchable by booking or customer, link them from alerts, and have the team read a few real traces every week, even when nothing is wrong.
9 Check yourself
Four quick questions
10 Do this today
Six steps to an agent you can see inside
Pick one agent you're building or buying. Work down this list. Your ticks are saved in this browser.
11 Questions people ask
Observability and tracing FAQ
What is agent observability?
Agent observability is the ability to see and understand what an AI agent did and why, at every step. It is built mainly on traces that record each model call, tool call, guardrail decision and human approval, with inputs, outputs, timing, cost and versions. It is what lets you debug, audit and improve an agent in production.
What is the difference between a trace and a span?
A trace is the full record of one task, from the request coming in to the final result. A span is one step inside that trace, such as a single model call or tool call, with its own start time, end time and details. Spans can be nested inside each other to show which step caused which.
What should you log for an AI agent?
For each step: what the model was shown, what it proposed, what the harness allowed or blocked and why, what each tool returned, how long it took, the tokens and cost, and which versions of the prompt, model, tools and rules ran. Record human approvals too. Remove personal data before storing.
What are the OpenTelemetry GenAI semantic conventions?
They are a shared set of names, defined by the OpenTelemetry project, for describing AI operations in traces, such as the model requested and the number of input and output tokens. Using them means different tools can read your agent traces the same way. They are still evolving, so some names may change between versions.
How do you keep personal data out of AI agent logs?
Redact or mask personal data such as card numbers, passport numbers, phone numbers and email addresses before a trace is stored, not afterwards. Keep references or statuses instead of raw values, limit who can read traces, and delete them after a set period that fits the data-protection rules where you operate.
How do traces help with AI agent evals?
Real traces are the best source of eval cases. When a trace shows a mistake, you can save its inputs and tool results, replay it against a fixed version to prove the fix works, and add it to your golden dataset so the same mistake is caught before any future release.
12 Glossary
Words you'll hear
- Observability
- Being able to understand what a system did and why from the data it records, including for questions you did not plan for.
- Trace
- The full, ordered record of one task, from request to result.
- Span
- One timed step inside a trace, such as a model call, tool call or guardrail check.
- Attribute
- A named detail attached to a span, such as the model used, the tokens or the result.
- Token
- A small piece of text a model reads or writes. Model usage and cost are usually counted in tokens.
- Latency
- How long something takes. For agents, usually the time from request to reply, and per step.
- p95
- The 95th percentile: the time within which 95% of requests finish. It shows slow cases an average hides.
- Redaction
- Removing or masking personal or sensitive data before it is stored.
- OpenTelemetry
- An open, vendor-neutral standard for collecting traces, metrics and logs, including evolving conventions for AI.
- Replay
- Re-running a recorded task on a new version, using the saved inputs, to check a fix.
For teams
Want your team to trace agents like this?
I run AI agents in production at estaie that set prices, find customers and look after guests. This page comes from building and running them.
AI Skills 2027, for your engineering team
A hands-on workshop where your engineers add tracing, cost tracking and alerts to a real agent from your business.
- One skill in depth, or all ten as a bootcamp
- On site in the UAE or remote
- Your team leaves with working code, not slides
Have your agent's observability reviewed
I check what your agent records against the failure types on this page and give you a written list of what to fix first, in order of risk.
- For teams about to launch, or just after an incident
- Plain-English findings your board can read
The series
All ten AI Skills for 2027
- Harness Engineering
- Loop Engineering
- Context Engineering
- Tool Design
- Memory Architecture
- Orchestration Patterns
- Guardrails & Permissions
- Evals for Agents
- Human-in-the-loop Design
- Observability & Tracing
Published 2 December 2026. Written by Nimit Solanki from building production agents at estaie.
Get the free Playbook by email
Seven short lessons on taking an agent from prototype to production. One a day, free. You may also hear about my course and consulting. Opt out any time.