Agent in Production
ObservabilityLong read

Moving Your AI Coding Agent From Post-Mortem Discovery to Real-Time Attributable Observability

Prevent agent incidents by linking every action to a person and enforcing policy before execution.

· 9 min read
Cover illustration for “Moving Your AI Coding Agent From Post-Mortem Discovery to Real-Time Attributable Observability”
Observability · November 5, 2026 · 9 min read · 1,971 words

Full observability for AI coding agent sessions needs end-to-end traces that link every tool call, file diff, and token to a person or trigger. It also requires policy and budget controls that act before execution. Moving from post-mortem discovery to real-time attributable observability is an infrastructure decision.

Why production AI coding agents fail silently, and why post-mortem discovery is structurally insufficient

An agent can delete a production database in seconds, while reconstructing what authorized that action without proper logging takes hours. That speed asymmetry makes retrospective investigation structurally insufficient. By the time an investigator assembles the sequence, the action has already crossed system boundaries and changed production state. A final response offers little evidence of how it happened.

Traditional monitoring can miss the failure entirely. An agent can return HTTP 200 with a confident wrong answer, call the right tool with the wrong argument, or exhaust a budget through retries. Request-rate dashboards do not distinguish these outcomes from useful work. When the agent has write access, a hallucination or instructions hidden in a retrieved document can escalate from an incorrect answer to an incident.

Agents operate across APIs, databases, and tools, each of which may expose only part of the run. Without a sequence that links those parts and can be audited, investigators cannot tell why an action happened or what authorized it. The failure is therefore not simply that an agent made a poor decision, but that the surrounding infrastructure cannot explain its consequences.

What agents actually do in production that makes them hard to observe

A production coding agent is best understood as a distributed transaction containing a non-deterministic component. One run spans model calls, retrievals, tool invocations, retries, and fallbacks. Each step can fail independently of the final response. A successful run that needed four retries can look identical to one that needed one when only the endpoint is observed.

In multi-agent systems, more agents take part in that transaction. Message passing, synchronization delays during handoffs, and collaborative decision quality become part of the execution path. Hierarchical tracing is needed to make these relationships visible. As context builds up, the transaction’s cost changes: a session that starts with a small context may send a very large context by step 20.

Prompts, tokens, and latency expose only part of this behavior. They do not establish whether retrieved data was appropriate or whether a tool accessed information within its permissions. A deprecated dataset or an unauthorized column can introduce governance risk without producing a service error. The transaction therefore has to be understood in its business, data, and policy context, including its connection to a lineage and policy graph.

The five observability signals a production agent run must emit

To close those gaps, a production run must emit five signals, namely traces, metrics, logs, evaluations, and policy decisions. Traces provide the causal spine. They show the order and nesting of model calls, retrievals, tool invocations, and retries. Metrics describe task-level performance through success rate, latency percentiles, tokens and cost per task, tool errors, escalations, and abandonment.

Logs supply the redacted prompt and response payloads, tool arguments, and results linked to the trace that produced them. Evaluations add evidence about correctness, groundedness, format compliance, and safety, using golden datasets offline and sampled live traffic. Policy decisions record what a guardrail allowed, blocked, redacted, or escalated, and why.

Application metrics also need four distinct views. Token usage exposes consumption, while quality measures capture hallucination rate and task completion. Latency shows where delays occur, and behavioral metrics show reasoning steps and patterns in tool selection. These views catch different failure modes, so counting tokens cannot replace measuring how well the task was done. Evaluations and policy decisions then distinguish an operationally successful run from one that was wrong or outside its authority.

Instrumenting end-to-end traces with OpenTelemetry and what each span must capture

OpenTelemetry is a starting point because its tracing model already describes distributed transactions. Its generative AI semantic conventions give telemetry common, queryable attribute names, although those conventions remain at Development status as of 2026, with Stable status still pending. Use gen_ai.operation.name, gen_ai.provider.name, gen_ai.request.model, gen_ai.usage.input_tokens, and gen_ai.usage.output_tokens at the relevant orchestration steps.

The root span should identify the tenant, user role, session, agent version, and prompt template version. Each model-call child span should capture model name and version, input and output token counts, temperature, finish reason, and computed cost. Retrieval children should record the index or collection, query, number of chunks returned, and cited document identifiers. Tool-call children should capture the tool name, hashed or referenced arguments, authorization decision, latency, and read-versus-write classification. Give retries and fallbacks explicit spans in this layout.

Propagate one trace identifier through every downstream service. Surface that identifier in support tooling so a complaint maps directly to its execution record. Keep prompt and response payloads in a redacted, access-controlled store, and put references to that store in span attributes. This preserves the causal connection to API and database telemetry without turning the telemetry backend into a repository of customer payloads or binding the record to a bespoke logging format.

Attribution: linking every agent action to a person or trigger before the run ends

A complete trace can explain what happened without proving who authorized it. Attribution closes that gap before the run ends. The audit record must identify the initiator, agent and prompt versions, model and version for each output, tool arguments and results, policies invoked, and human approvals or overrides. Otherwise, the investigation still depends on reconstructing authority after consequences appear.

Identity-bound logging connects actions to an authenticated user through OAuth 2.0, SAML, or OIDC. An MCP Gateway places authentication, authorization, and logging at one control point between coding agents and their tools. It validates permissions, records actions, and enforces policy before forwarding requests. This avoids scattering the accountability boundary across developer machines and MCP servers.

Every tool call needs six essential data elements. Those are the input prompt or instruction, generated or modified output, data accessed, model identity and version, authenticated user identity, and a precise timestamp. For coding work, the modified output includes the file diff that connects an action to its effect. The organization must also keep evidence on infrastructure it controls, even if a third party keeps logs. That control is the operational basis of audit sovereignty.

Guardrails that act before the tool call, not after the damage

Attribution establishes responsibility, but prevention requires an execution boundary. Runtime governance must sit between the model and tool execution, evaluating a proposed call before it proceeds. The Microsoft Agent Governance Toolkit illustrates this deterministic enforcement approach. A blocked operation cannot reach the tool through that governed path, which is fundamentally different from an alert reporting a completed destructive action.

Least-privilege scopes constrain what the agent can request. Read-versus-write classification provides an enforcement trigger, while irreversible actions require human approval. A tiered permission model can auto-approve changes with little risk, such as dependency bumps and documentation updates. Logic changes, schema migrations, and authentication or payment code require human approval, making autonomy proportional to the action’s risk and reversibility.

The enforcement decision must remain visible even when no tool executes. Policy telemetry records the reason for allowing, blocking, redacting, or escalating the request. When an agent attempts to access environment files, SSH keys, or production credentials, real-time monitoring should alert before access completes. The preventive control changes the security posture.

Budget caps as a real-time control, not a post-hoc audit metric

Session-level budget caps must constrain consumption before it occurs, rather than leave the invoice as the first effective control. As context grows, the cost per call can change. Multi-agent loops compound that exposure when neither a budget limit nor an acted-upon alert interrupts execution.

The control architecture needs several independent limits. Token budgets, model-call limits, tool-call limits, retry budgets, and dollar caps bound different routes to excessive consumption. Downgrade rules and graceful termination govern what happens when the remaining budget cannot safely finish the task. A reviewer agent, for example, can have both per-day and per-task caps, multiple alert thresholds, and an explicit on_exceed setting of pause_and_alert.

Degradation must follow declared thresholds. At a high percentage of remaining budget, the configuration can switch to a fallback model. A medium threshold can apply context compression, while a lower threshold disables non-critical retrieval and preserves required reads. These YAML-expressed limits belong in the same repository as the agent configuration, because spending authority is part of the agent’s definition.

Agent configuration as versioned, reviewable code — not operational state

Configuration stored outside the repository can drift away from the controls reviewers approved. YAML-defined sandbox permissions, credential scopes, budget caps, guardrail rules, and model versions make that authority a versioned artifact. Changes then have a reviewable history. The same release process can govern what the agent may do and how its behavior is observed.

NVIDIA’s OpenShell, launched at GTC Berlin 2026, illustrates the broader pattern of YAML-driven sandbox policy. Its security policies set filesystem access, the process user and group, and network endpoints, and each rule has an enforcement mode. The pattern supports governance through declarative files across choices of agent.

Release rigor also applies to prompts and tool definitions. Although these are configuration rather than application code, they need version pinning, CI-gated evaluation suites, and one-click rollback. Changes to a prompt, tool schema, retrieval index, or model version must clear the golden dataset before release. A modular, microservices-inspired architecture then allows individual sub-agents to be replaced as models evolve without changing the entire system.

Regulatory requirements that are already in force and those arriving in 2026

Regulatory enforcement, work on standards, and security guidance each put a different kind of pressure on organizations. They should not be treated as interchangeable mandates. The FTC has already used its enforcement powers to impose 20-year audit orders on companies that made inaccurate AI claims. Such orders are enforcement measures specific to the companies subject to them.

NIST’s Center for AI Standards and Innovation started the AI Agent Standards Initiative on February 17, 2026. The initiative focuses on interoperability and security standards for agentic AI systems. In April 2026, CISA, NSA, ASD ACSC, the Canadian Centre for Cyber Security, NCSC-NZ, and NCSC-UK jointly published “Careful Adoption of Agentic AI Services.” These developments establish government attention to agent security, but do not by themselves create a blanket logging obligation.

The ACM AI Leadership Summit 2026 formalized five auditability dimensions in an “Auditability Card” framework. They are action recoverability, lifecycle coverage, policy checkability, responsibility attribution, and evidence integrity. Clean audit exports also support SOC 2, HIPAA, and GDPR compliance workflows, without making the architecture alone proof of compliance. AI legislation does not set one log retention period for all cases. Applicable obligations therefore require precise interpretation, while attributable records provide reusable evidence across reviews.

What the full observability stack looks like when it is running in production

In production, isolated sandboxes bound each session’s access, with fresh credentials minted for the session and revoked on completion. Every tool call, file diff, and token is logged and attributable to a person or trigger. Budget controls operate at session, developer, and time-period levels. The trace links these controls to the run, so the records show how the controls applied during execution.

Evaluation and configuration complete the operating model. Offline evaluation suites gate releases in CI, while online evaluations assess sampled live behavior. YAML-defined configurations preserve the history of permissions, model choices, budgets, and guardrails. Together, these records let a team relate an observed action to the approved configuration that governed it, while live enforcement prevents disallowed actions from proceeding.

A laptop deployment remains a prototype of this architecture. Managed infrastructure with governance makes these controls a required part of running agents in production. The infrastructure decision changes the question from forensic reconstruction after an incident to continuous, attributable assurance that agents are operating within policy.

Filed underObservability

More in Observability