name: agent-observability-tracing
description: Instrument agent runs so model calls, skill versions, tool calls, latency, failures, and costs can be reconstructed from correlated telemetry.
metadata:
source: skills/09-agentic-patterns/agent-observability-tracing.md
category: 09-agentic-patterns
version: "v1"
Agent Observability Tracing
Description
Create correlated telemetry for agent execution so a complete run can be reconstructed without relying on model self-report. Capture agent/session identity, skill version, model invocation, tool invocation, latency, outcome, and relevant cost/token metadata while excluding secrets and unnecessary sensitive content.
When to Use
- Debugging multi-step agent execution.
- Measuring skill invocation and failure behavior.
- Attributing latency, tokens, or cost across agent/tool chains.
- Verifying which skill version actually ran.
Inputs / Outputs
| Area |
Contract |
| Inputs |
Agent run, correlation/trace ID, skill identity/version, model/tool calls, timestamps, outcome metadata, and telemetry policy. |
| Outputs |
Structured logs/metrics/traces with correlated spans and explicit outcome/error fields. |
| Evidence |
Telemetry must identify the executed component/version and distinguish observed data from inferred conclusions. |
Procedure
- Define the operational questions the telemetry must answer.
- Establish a stable run/trace identifier and propagate it through model, skill, and tool calls.
- Emit structured spans for skill selection, skill execution, model calls, and tool calls.
- Record versioned skill identity and execution outcome.
- Record latency and token/cost data only when actually available.
- Redact secrets and sensitive payloads before export.
- Verify that an induced failure can be reconstructed from telemetry alone.
Runnable Example
trace = {"trace_id": "run-001", "skill": "agent-observability-tracing", "version": "v1"}
trace["events"] = [{"kind": "tool", "name": "search", "status": "ok"}]
assert trace["trace_id"] and trace["events"]
print(trace)
Failure Modes
- Missing correlation IDs break call-chain reconstruction.
- Skill/version attribution is absent or inferred incorrectly.
- Cost is reported from guessed pricing rather than observed instrumentation.
- Logs contain credentials or raw sensitive prompts.
- Metrics use unbounded labels and create cardinality explosions.
- A successful span is mistaken for proof of a successful side effect.
Security Boundary
Telemetry is an evidence surface, not an authorization surface. Never expand permissions to improve observability.
Evidence
Public 2026 ecosystem requests explicitly seek OpenTelemetry/observability hooks for MCP and agent skill evaluation, including attribution of agent, skill version, model calls, tool calls, latency, and cost.
Related
- audit-logging.md
- mcp-tool.md
- agent-evaluation.md
- tool-execution.md
1---2name: agent-observability-tracing-23description: Instrument agent runs so model calls, skill versions, tool calls, latency, failures, and costs can be reconstructed from correlated telemetry.4---5---6name: agent-observability-tracing7description: Instrument agent runs so model calls, skill versions, tool calls, latency, failures, and costs can be reconstructed from correlated telemetry.8metadata:9 source: skills/09-agentic-patterns/agent-observability-tracing.md10 category: 09-agentic-patterns11 version: "v1"12---1314# Agent Observability Tracing1516## Description17Create correlated telemetry for agent execution so a complete run can be reconstructed without relying on model self-report. Capture agent/session identity, skill version, model invocation, tool invocation, latency, outcome, and relevant cost/token metadata while excluding secrets and unnecessary sensitive content.1819## When to Use20- Debugging multi-step agent execution.21- Measuring skill invocation and failure behavior.22- Attributing latency, tokens, or cost across agent/tool chains.23- Verifying which skill version actually ran.2425## Inputs / Outputs26| Area | Contract |27|---|---|28| Inputs | Agent run, correlation/trace ID, skill identity/version, model/tool calls, timestamps, outcome metadata, and telemetry policy. |29| Outputs | Structured logs/metrics/traces with correlated spans and explicit outcome/error fields. |30| Evidence | Telemetry must identify the executed component/version and distinguish observed data from inferred conclusions. |3132## Procedure331. Define the operational questions the telemetry must answer.342. Establish a stable run/trace identifier and propagate it through model, skill, and tool calls.353. Emit structured spans for skill selection, skill execution, model calls, and tool calls.364. Record versioned skill identity and execution outcome.375. Record latency and token/cost data only when actually available.386. Redact secrets and sensitive payloads before export.397. Verify that an induced failure can be reconstructed from telemetry alone.4041## Runnable Example42```python43trace = {"trace_id": "run-001", "skill": "agent-observability-tracing", "version": "v1"}44trace["events"] = [{"kind": "tool", "name": "search", "status": "ok"}]45assert trace["trace_id"] and trace["events"]46print(trace)47```4849## Failure Modes50- Missing correlation IDs break call-chain reconstruction.51- Skill/version attribution is absent or inferred incorrectly.52- Cost is reported from guessed pricing rather than observed instrumentation.53- Logs contain credentials or raw sensitive prompts.54- Metrics use unbounded labels and create cardinality explosions.55- A successful span is mistaken for proof of a successful side effect.5657## Security Boundary58Telemetry is an evidence surface, not an authorization surface. Never expand permissions to improve observability.5960## Evidence61Public 2026 ecosystem requests explicitly seek OpenTelemetry/observability hooks for MCP and agent skill evaluation, including attribution of agent, skill version, model calls, tool calls, latency, and cost.6263## Related64- audit-logging.md65- mcp-tool.md66- agent-evaluation.md67- tool-execution.md