A production guide to AI agent observability across traces, tool calls, model outputs, permissions, latency, cost and failure analysis.

Why agents need a different observability model

Traditional applications expose requests, errors and resource metrics. An AI agent adds non-deterministic model calls, retrieval, planning and tool execution. A successful HTTP request can still produce a bad business outcome. Teams therefore need traces that connect the user’s goal to each model call, retrieved context, proposed action, policy decision and tool result. Trace the full task graph. A useful trace assigns one task ID to the entire run and child spans to reasoning steps, model requests, retrieval queries and tool calls. Store timing, model version, token usage, tool name and outcome. Sensitive prompts or data can be redacted while preserving metadata. The objective is to reconstruct what happened without relying on a user’s screenshot.

Separate model errors from system errors. A hallucinated parameter, a permission denial, a tool timeout and a malformed API response require different fixes. Classify failures by layer. Model-quality problems may need better instructions or evaluation; tool failures need retries and contracts; permission failures may be correct behavior. One generic ‘agent failed’ metric hides the information engineers need.

Measure outcomes. Latency and token cost matter, but task success is the primary metric. Define success for each workflow: ticket resolved, record updated correctly, report generated with required fields or human approval obtained. Capture partial success and unnecessary tool calls. This makes it possible to compare models and orchestration strategies against business outcomes rather than benchmark scores alone.

Permissions belong in the trace

Every action should record which identity requested it, which policy allowed it and what scope was used. This is especially important when agents can write to business systems. MidyTech’s earlier guide to least-privilege AI agent permissions provides the control layer; observability provides the evidence that those controls behaved as intended. Cost attribution. Agent tasks can call several models and tools. Attribute inference, retrieval and external API cost to the task and, where useful, to a customer or workflow. Average cost alone can hide expensive failure loops. Percentile distributions reveal tasks that repeatedly retry or send oversized context.

Build an evaluation loop. Sample failed and successful traces into an evaluation dataset. When prompts, models or tools change, replay representative tasks and compare success, latency and cost. Production traces become the source of realistic test cases. This closes the gap between lab evaluation and actual enterprise work.

Operational dashboard. A practical dashboard includes task success rate, human-escalation rate, tool error rate, policy denials, p50/p95 latency, cost per successful task and top failure classes. Alerts should focus on material changes rather than every model variation. Agent observability is ultimately about making probabilistic software operable with the same discipline as other production systems.

Implementation checklist

  • Define a measurable service objective.
  • Instrument cost, latency and failure modes.
  • Test with representative production workloads.
  • Preserve permissions and rollback paths.
  • Review architecture as models and prices change.

Give every external action a contract. The runtime should know each tool’s schema, required permission, expected side effect and evidence of success. Natural-language descriptions help the model choose tools, but application code should enforce the contract before execution.

Contracts also make retries safer because the runtime can verify whether an intended effect already happened.

Persist checkpoints outside model context

Approvals, completed steps and external receipts belong in durable workflow state rather than a conversation summary. The model should receive only the relevant state for the next decision. This reduces context size and prevents summarization from becoming the source of truth for irreversible work.

Test partial failure deliberately. Simulate timeouts, duplicate callbacks, stale credentials and delayed approvals. A reliable workflow ends each case in a known state with a clear next action instead of depending on manual investigation.

Make workflow state durable

Production agents need explicit states such as validated, executing, committed, failed and waiting for review. Storing these outside the prompt prevents a regenerated plan from repeating an action that already succeeded and gives recovery a precise restart point. External side effects also need idempotency keys, receipts or verification so a timeout does not turn into a duplicate purchase, email or database change.

Separate planning from execution authority. The model can propose an action, but deterministic application logic should decide whether the current identity, arguments and workflow state are allowed to execute it. This keeps reasoning flexible while the action boundary remains enforceable.

Testing can then evaluate plan quality separately from tool safety and recovery.

Instrument recovery paths

Track tool latency, retries, approval wait time, state-transition failures and manual repair rate. Traces should connect the model decision to the external effect so teams can distinguish reasoning errors from orchestration defects.