What the Observability Gap Looks Like When Tool Calls and Diffs Are Not Captured at the Principal Layer
Without tool-call and diff capture, incidents, audits, and costs go unexplained.

Full observability for AI coding agent sessions requires tool calls, file diffs, and per-turn token attribution captured at the principal layer, where human identity, session credentials, and policy govern the work. Output logs cannot reconstruct how an authorized request became a code change. Closing that gap requires structured session traces, enforceable configuration, and durable audit records, so incident response, compliance, and cost attribution share a reliable chain of evidence.
Why output logs are not enough once an agent can act on the world
A clean output log can show that an agent returned successfully while omitting the action that introduced a security bug. The agent can return 200 OK, pass partial tests, and leave application monitoring green. No exception needs to occur for this failure. Traditional monitoring assumes a predictable request-response contract, in which code follows a fixed path and the response shows how that code ran. An agent’s final answer is a weaker signal because consequential actions can precede it.
Agents break that contract through non-determinism, external state mutation, and multi-step execution. The same task can produce different sequences of steps, while API calls, pull requests, database queries, and transactions change systems before the answer appears. A wrong decision at step three may become visible only at step twelve, after it has caused downstream effects. Individual spans can still look entirely healthy. In a tool-call loop, every model call may finish within normal latency bounds while the session burns tokens without progressing. Whether the service is up therefore says little about whether the agent chose the right tool, passed valid arguments, or stayed on plan.
What the principal layer is and why capturing actions there is structurally different from application logging
The principal layer authorizes work. It holds the identity of the human who triggered the workflow, the credentials scoped to the session, and the policy governing what the agent may do. This is where authority becomes attached to execution. Application logs below that layer may record that a service account touched a system, but not which employee initiated the workflow or how authority passed through sub-agents.
Capturing actions at this boundary connects the prompt delivered to the model with the resulting actions and their authorization. The prompt includes retrieved context and injected content, while the execution record includes model responses, tool parameters, results, and correlation IDs. Human identity must survive each sub-agent handoff. System prompt, tool manifest, and model versions show which configuration was in use during the run, which may differ from the configuration deployed now.
That record is distinct from permission enforcement. OpenTelemetry spans and audit trails describe runtime behavior, whereas pre-execution checks permit or deny an action. Neither discipline substitutes for the other. System-prompt instructions can reduce the probability of an unwanted path, but they do not create a strict authorization boundary. Treating those instructions as controls leaves policy dependent on the behavior it is supposed to constrain.
How the missing tool-call record makes incident reconstruction impossible
Consider an investigation into a silent authentication regression discovered the morning after a multi-agent coding session. A four-hour session can produce more than 180 tool calls, leaving investigators to identify which agent wrote the broken code, what context it had, and which actions produced the final state. Health checks can remain green because the regression does not have to produce an application failure. Without the tool-call record and associated diffs, the investigation cannot establish the action that introduced it.
A handoff makes that search harder. An orchestrator may hand off work with faulty context that leads another agent to make the damaging change, so the symptom occurs in that agent’s work after the original error. Without a shared trace ID across the call graph, those events have no link to each other. A service-account access record cannot bring back the missing context or show which employee authorized the work. Investigators are left with partial evidence when they need a causal chain to scope the blast radius and prevent recurrence.
OpenTelemetry GenAI semantic conventions model an agent run as a parent span with child spans for model calls and tool invocations, supplying a minimum structure for reconstruction. Prompts and completions are opt-in content. Teams must therefore decide what content to capture and retain before an incident occurs.
How the same gap collapses audit and compliance the moment regulators ask for evidence
An audit asks for the same causal chain, but with authorization and retention under scrutiny. The record must show what the agent did, on whose authority, and in what sequence. Debugging and compliance fail at the same missing link. A dashboard that resets each session cannot keep evidence for later, while an audit trail with only timestamps and status codes cannot explain the action being reviewed. Observable content and retained records have to work together.
The EU AI Act establishes logging and retention obligations for high-risk AI systems, making structured evidence a compliance requirement. NIST started the AI Agent Standards Initiative in February 2026 to work on agent identity, authorization, security, and interoperability. The OWASP Top 10 for LLM Applications 2026 names excessive agency as a vulnerability class. These frameworks differ in purpose and legal force. Their relevance here is that agent actions and their permitted scope require explicit treatment, rather than being inferred from a successful response.
Retention also depends on the applicable obligation. HIPAA-covered entities keep security documentation for six years, but the rules differ by sector, jurisdiction, and use case. That does not establish one universal retention window for agent traces. Where privileged access is involved, principal-layer evidence also exposes discrepancies between intended role-based access controls and actual agent behavior, allowing the audit to examine enforcement alongside policy statements.
Why cost attribution collapses without per-turn, per-session telemetry
An arXiv study found up to 30x variance in token usage for the same coding-agent task, making aggregate consumption a poor basis for predicting individual runs. An agent can loop overnight while other agents run concurrently, accumulating spend through calls that each look operationally normal. Without per-turn telemetry, the bill reveals the consequence after the opportunity to intervene has passed.
Model changes introduce another source of unpredictability. A newer tokenizer can produce more tokens for the same text even when the per-token price is unchanged, raising request costs without an obvious difference in output. A model migration without recalibrated token-budget controls can therefore undermine an existing spending policy. Attribution needs to connect usage to the session, agent, tool call, and initiating user as well as to an aggregate billing account.
Portal26 launched “Agentic Token Controls” in April 2026, with budgets at the agent, workflow, or organization level and safeguards that throttle, pause, or terminate execution. The product illustrates a distinction between reporting spend and controlling it. Visibility alone cannot stop an expensive session. Engineers aim to keep work predictable and within clear limits before a workflow uses up the budget and leaves them to find out what happened.
How do teams get complete visibility into every tool call and file diff?

Tool-call spans record the tool name, arguments, raw output, duration, retry count, and error state. Those fields distinguish valid progress from silent retries. File diffs link editing actions to the changes they made, and per-turn token telemetry records the tokens used in the same session record. This makes code changes and their cost attributable to specific execution steps.
The trace also needs context beyond tool invocations. Reasoning spans record the model’s expressed plan, chosen action, observation, and next decision, making plan drift visible across steps. State-transition spans capture working memory before and after steps, context edits, and handoff payloads. Memory-operation spans record long-term-store reads and writes, including queries, returned entries, relevance scores, and freshness. Together, they can reveal context loss, wrong-branch selection, stale retrieval, and memory leakage that aggregate metrics cannot explain.
The principal-layer record binds those spans to authorizing identity and the versions of the system prompt, tool manifest, and model. Tamper-evident storage makes that evidence defensible months later. Enforcement remains a separate requirement from this visibility. A propose/dispose pattern in CI illustrates the distinction through a read-only repository mount, one writable output directory, allowlisted egress, and short-lived scoped credentials. A separate human-approval job precedes applied writes, while protected paths define scope before execution.
How agents-as-code and version-controlled configuration make the principal layer enforceable, not just observable
For those boundaries to be enforceable, agent permissions, tool scope, and spending limits must exist as versioned configuration reviewed and deployed like code. Declarative YAML security policies illustrate this separation between agent behavior and the rules governing it. Configuration becomes an inspectable part of the control plane. Checked-in policies provide review and version history, much as Terraform configurations do for cloud infrastructure. The runtime then operates against an explicit policy rather than an informal instruction embedded in a prompt.
Agent configuration is also an attack surface. A campaign put persistent startup commands in hidden agent configuration directories, showing how configuration changes can affect what runs before ordinary interaction begins. Google GTIG’s threat tracker describes credential-harvesting rules aimed at the configuration stores of AI coding assistants, which can hold plaintext API keys. Version control keeps a record of policy changes, and review puts those changes through a security check before they are deployed.
Credential lifecycle is a second enforcement dimension. Each agent session should receive credentials minted for that session and revoked when it ends, rather than relying on authority that outlives the work. Revocation prevents reuse of the expired session’s credentials. This is a principal-layer responsibility because the restriction must apply when access is attempted. The NIST initiative reinforces the broader framing of agent identity and authorization as infrastructure concerns.
What engineering teams running agents in production need to close the gap today
For production teams, the practical response is to build structured traces, enforceable configuration, and durable audit records together. Incident reconstruction requires tool-call, reasoning, state-transition, and memory-operation spans as first-class telemetry, with file diffs captured at the session level. A single trace ID must cross every agent and sub-agent handoff. That link lets investigators follow a failure back through intermediate states without having to piece together unrelated service logs.
For audit, teams should retain the delivered prompt, model response, tool parameters and results, authorizing identity, and governing configuration versions in tamper-evident storage. Teams should keep the records for as long as the rules for their sector require. Session, developer, and time-period budgets should be enforced using per-turn telemetry, so loops and model-migration cost inflation can trigger controls before spend accumulates.
Data boundaries remain a legitimate architectural constraint. Keeping source code and process execution self-hosted can address concerns over data egress from managed cloud agents, and teams can keep that control while meeting governance needs. The platform should be built so each session can enforce its data-boundary constraints. The final test is whether the team can reconstruct a meaningful action from the initiating human, through every tool call and intermediate state, to the final diff without stitching logs across systems. If it cannot, the principal-layer gap remains open regardless of dashboard health.


