Blog

    Observability for Agentic AI in Healthcare: Traces, PHI Redaction, Retention and Per-Tool Alerts

    By GauravNovember 27, 20269 mins read
    On this page

    An AI agent in production does not fail like a normal service. It can return a polite answer while a tool call behind it failed, loop through the same lookup over and over, or quietly run up model costs, and the request log shows only that a response was sent.

    This post is for engineering and operations teams running agents in healthcare settings. It covers what a trace should capture per run, how to keep protected health information out of traces, how long to keep them, and which alerts catch problems before clinicians or patients do.

    What is observability for agentic AI in healthcare?

    Running AI agents in clinical or administrative workflows?

    Our agentic AI page covers how we design, build and operate agents for healthcare organisations.

    Observability for agentic AI in healthcare is the ability to see, for every agent run in production, which steps it took, which tools it called, what each cost and where it failed, without exposing protected health information. Agnotic Technologies instruments agents so each run can be traced, alerted on and replayed for an incident review.

    Monitoring tells you that something is wrong. Observability lets you ask why, after the fact, about a run nobody expected to fail.

    What should a trace capture for each agent run?

    A trace should capture the whole run as a tree: the request, each reasoning step, each model call, each tool call and each handoff, with timings, status and cost. The structure matters as much as the content.

    OpenTelemetry defines a span as a unit of work or operation and the building block of a trace; each span carries a name, a parent span ID, start and end timestamps, attributes, events and a status, and child spans represent sub-operations.

    • Run span: request type, user role, agent version, prompt version and the outcome.
    • Model spans: model name and version, tokens in and out, latency and stop reason.
    • Tool spans: tool name, target system, result status, retries and duration.
    • Handoff spans: which human or agent took over and why.

    Use one trace format across every agent you run. When a second or third agent goes live, shared span names and tags let one dashboard compare them instead of each team inventing its own.

    Spans for every step and tool call

    Give every tool call its own span, even when the call is fast and usually succeeds. Most agent incidents start at a tool: an EHR API timing out, an eligibility service returning an empty answer, or a search tool returning the wrong patient.

    Record the tool's result status separately from the agent's final answer. An agent can recover gracefully from a failed tool in the user's eyes while the failure rate for that tool climbs unnoticed.

    Tag each span with stable identifiers: run id, agent version and tool version. Those tags let you compare behaviour before and after a change without reading individual traces.

    How do you keep PHI out of traces?

    Keep PHI out of traces by redacting or tokenising at the collector, before anything is stored, and by keeping prompt and response payloads apart from searchable metadata. Most engineers need timings and statuses, not patient text.

    Runtime observability for a healthcare AI agent: the agent runtime emits a span for every model call, tool call and handoff, a collector redacts PHI and splits metadata from restricted payloads, the trace store keeps searchable metadata and short-lived restricted content, and alerts and dashboards watch per-tool errors, cost, loops and latency, with access logging across every layer
    • Metadata by default: span names, timings, statuses, token counts and ids go to the main trace store.
    • Payloads restricted: prompts, tool inputs and outputs go to a separate store with tight access, or are not kept at all.
    • Tokenise identifiers: replace patient and member ids with tokens that only an authorised lookup can reverse.
    • Test redaction: run known PHI samples through the collector and check the store for leaks.

    Treat the observability vendor like any other system that may touch PHI. If payloads leave your boundary, the vendor needs the right agreement and security review first.

    How long should traces be kept?

    Keep searchable metadata long enough for trend analysis and investigations, and keep restricted payloads only as long as incident review needs them. Write the periods into policy rather than accepting a tool's default.

    The HIPAA Security Rule's audit controls standard requires mechanisms that record and examine activity in information systems that contain or use electronic protected health information.

    Agent traces are not a full substitute for the audit logs of the systems the agent touches. The EHR or claims system keeps its own audit trail; agent traces explain what the agent did and why, and both should share a run id.

    Which alerts should an agent have in production?

    An agent needs alerts per tool and per behaviour, not only on overall error rate. Averages across all runs hide a single failing integration.

    • Tool error rate: per tool, compared with its own normal level.
    • Loop detection: runs whose step count passes a limit for that task.
    • Cost spikes: tokens or spend per run above an expected range.
    • Handoff rate: share of runs escalated to humans, rising or falling sharply.
    • Write actions: any call that changes data in another system outside expected patterns.

    OWASP defines excessive agency as the vulnerability that lets an LLM application take damaging actions in response to unexpected, ambiguous or manipulated model output, usually caused by excessive functionality, permissions or autonomy.

    Route each alert to the team that owns the tool or behaviour, with a link to sample traces. An alert that lands in a shared channel without an owner is soon ignored.

    Cost and token tracking per tool

    Track cost per run and per step, then roll it up by task and tool. A small change in how an agent uses a search tool can double the tokens it sends to the model.

    Compare cost with outcome. A run that costs more but completes without a human handoff may be fine; a run that costs more and still escalates points to a loop or a poor tool result.

    What goes wrong with agent observability?

    Agent observability fails when it was added after launch, copied from web service monitoring, or set up without privacy review.

    • Request-only logging: the final response is logged but tool calls are invisible.
    • PHI in traces: full prompts stored in a tool many engineers can search.
    • Average-only alerts: one failing tool hidden inside an overall error rate that looks normal.
    • No versions on spans: behaviour changes after a prompt edit and nobody can tell when it started.
    • Sampling away failures: random sampling drops the rare runs that matter most.

    Each has a direct fix: span every tool, redact at the collector, alert per tool, tag versions and always keep error traces.

    A worked example: a prior authorization agent that starts looping

    A health system runs an agent that gathers documentation for prior authorization requests. One morning, the loop alert fires: some runs pass the step limit for the task.

    The on-call engineer filters traces by the alert and sees each looping run calling the document search tool repeatedly with the same query. The tool's spans show empty results since a change to the document index overnight.

    The team rolls back the index change, and step counts return to normal. Restricted payloads were not needed; spans with tool names, statuses and timings were enough to find the cause.

    How should traces support incident review?

    Traces should let a reviewer rebuild what an agent did in a specific run: the steps, the tools called, what each returned and where a human took over. That reconstruction is the core of any incident review involving an agent.

    • Find the run: search by run id, time, user role or the record the agent worked on, using tokens rather than identifiers.
    • Read the tree: follow spans in order to see where the run went wrong.
    • Open payloads only if needed: request restricted content through a logged, approved access path.

    Record the finding against the run id and the versions involved. The next review can then check whether the same tool or prompt version caused trouble before.

    Who owns what?

    Agent observability crosses platform, product, privacy and operations teams, and each owns a different part.

    • Platform team: instrumentation libraries, the collector, redaction and the trace store.
    • Agent product team: span names, version tags, alert thresholds and dashboards for their agent.
    • Tool owners: the error and latency alerts for the systems their tools call.
    • Privacy and security: payload retention, access rules and vendor review.
    • Operations: on-call rotation, runbooks and incident reviews.

    How do you check the observability itself works?

    Check it by injecting known failures in a test environment and confirming they appear as the right spans and alerts. Observability that has never been tested tends to fail during the first real incident.

    • Fault injection: make a tool time out and confirm the span, status and alert.
    • Redaction test: send synthetic PHI through a run and search the store for it.
    • Loop test: force a repeated step and confirm the loop alert fires.
    • Replay drill: rebuild a past run from traces during a practice incident review.

    What are agentic AI observability best practices?

    Trace every run as a tree with spans for each model call, tool call and handoff, and tag spans with agent, prompt and tool versions. Redact PHI at the collector and keep payloads in a restricted store.

    Alert per tool and per behaviour, keep every error trace, set retention in policy and test the whole setup with injected failures.

    How Agnotic can help

    Agnotic builds and instruments AI agents for healthcare organisations: span design, collectors with PHI redaction, trace storage with retention rules, per-tool alerts and incident runbooks. We fit the setup to your existing monitoring tools and privacy controls.

    Build agents with privacy controls from the start

    Our HIPAA-ready AI agent development covers access control, audit logging and PHI handling for agents.

    Sources

    Frequently Asked Questions

    Monitoring tracks known signals such as error rate. Observability records enough about each run, including steps and tool calls, to investigate problems nobody predicted.

    Talk to an engineer about your project

    Share your agent's tasks, tools and current monitoring. We will outline the traces, redaction and alerts it needs.

    Go deeper

    Services and solutions on this topic