AI Workflow Automation

AI Agent Observability: What to Log and How to Debug Production Failures

6 min read

Logging the right things at agent runtime makes the difference between debugging in 5 minutes vs. 5 days. Here is the schema we deploy with every enterprise AI engagement.

The Minimum Viable Agent Log Schema

  1. 01trace_id + span_id (OpenTelemetry)

    Always start here. Every agent call gets a trace.

  2. 02Input payload + content hash

    Hash for replay; payload for debugging.

  3. 03Prompt version (git SHA) + model version

    Pin the exact prompt + model that produced the output.

  4. 04Tool calls — name, input, output, latency

    Every tool invocation, fully serialized.

  5. 05Token counts (input, output, cached)

    Cost reconciliation + drift detection.

  6. 06Validation gate results

    Schema pass/fail, range checks, anomaly checks.

  7. 07Final action taken (or human-review fallback)

    Closes the audit loop.

Production-Grade AI Agent ArchitectureThree layers that keep enterprise agents reliableInputStructured payloadLAYER 1Deterministic BoundarySchema-bounded LLM callLAYER 2Validation GateSchema · Range · Cross-refPASS→ Final actionFAIL→ Human reviewLAYER 3 · Audit TrailEvery decision logged: input → prompt → output → action
The 3-layer architecture pattern Ohveda uses to ship reliable, auditable enterprise AI agents to production.

Sample Log Record

{
  "trace_id": "01HZQ3...4F",
  "span_id":  "7B91...8A",
  "agent":    "ticket-triage-v2",
  "prompt_sha": "abc123",
  "model": "claude-3-7-sonnet-20250219",
  "input_hash": "sha256:5f...e2",
  "tool_calls": [
    {"name": "fetch_customer_tier", "input": {"customer_id": "c-882"}, "latency_ms": 38},
    {"name": "fetch_recent_tickets", "input": {"customer_id": "c-882"}, "latency_ms": 112}
  ],
  "tokens": {"input": 1840, "output": 220, "cached": 980},
  "validation": {"schema_ok": true, "range_ok": true},
  "result": {"category": "billing", "priority": "P2", "confidence": 0.91},
  "action_taken": "routed_to_billing_queue"
}

Ready to optimize your cloud or AI footprint?

Book a free 30-minute architecture review. We will deliver a written cost-and-architecture audit within 48 hours.

Book a free architecture review · sales@ohveda.com

Need help with AI agent observability?

Ohveda runs free 30-minute architecture reviews. We will identify your top opportunities in writing within 48 hours — at no cost.

Book a Free Architecture Review →