Observability

Conceptual

Traces, metrics and alerts for agents in production.

Production is the real evaluation. Every run emits a structured trace so you can answer "why did it do that?" long after the run has ended.

Trace contents#

  • The plan, every revision to it, and the reason for each revision.
  • Every tool call: arguments hash, latency, retries, result size, policy decision.
  • Every observation and how it changed the plan.
  • Model routing decisions per step.
  • Approval requests, who decided, and how long it took.
  • Budget consumption over the run timeline.

Metrics worth alerting on#

MetricAlert whenUsually means
Task success rateDrops week over weekUpstream change or drift
Steps per task (p95)Rises without success gainPlanning degradation
Tool error rateSpikes for one toolUpstream breakage or schema drift
Approval rejection rateRisesAgent proposing the wrong actions
Policy denial rateRises sharplyMisconfiguration or attempted misuse
Cost per completed taskRises faster than volumeInefficient routing or retry storms
Injection attempts detectedAny sustained increaseTargeted activity
ts
export async function POST(req: Request) {
  const event = await verifyWebhook(req);

  if (event.type === class="tok-str">"policy.denied") {
    metrics.increment(class="tok-str">"pimsy.policy.denied", { tool: event.tool, rule: event.rule });
    if (event.rule === class="tok-str">"codebase.dependency_add") await pager.page(class="tok-str">"agent-policy-denial");
  }

  return new Response(null, { status: class="tok-num">204 });
}

Last updated 2026-09-11