agentskit.js

@agentskit/observability — for agents

Console + LangSmith + OpenTelemetry logging, token counters, cost guard, trace viewer, signed audit log, devtools server.

#Install

npm install @agentskit/observability

#Primary exports

#Loggers / tracers

  • consoleLogger(config?) — local dev logging.
  • langsmith(config) — LangSmith observer.
  • opentelemetry(config) — OTel observer.
  • createTraceTracker({ onSpanStart, onSpanEnd }) — low-level span lifecycle.

#Sinks (batch HTTP exporters)

  • datadogSink(config) — Datadog Logs intake.
  • axiomSink(config) — Axiom dataset ingest.
  • newRelicSink(config) — New Relic Log API.

#Guards + counters

  • costGuard(options) — dollar ceiling per run.
  • multiTenantCostGuard(options) — per-tenant cost cap with shared bookkeeping.
  • createAdvancedCostGuard({ budgets, caps, mode, disableRuntime, alertSinks }) — production-grade guard with warn / reject / kill modes, rolling window caps (perMinute / perDay / perMonth / custom), 50/80/100 % threshold alerts, linear forecast alerts, and pluggable sinks.
  • consoleAlertSink(), webhookAlertSink({ url, headers }), throttle(sink, windowMs) — built-in alert sinks.
  • chargebackReport(samples, { groupBy, from, to }) + chargebackReportToCsv(report) — pure cost-attribution exporter for finance / per-tenant invoicing.
  • priceFor, computeCost, DEFAULT_PRICES.
  • approximateCounter, countTokens, countTokensDetailed, createProviderCounter.

#PII redaction

  • wrapObserverWithRedaction(observer, { rules, mode?, vault?, allowedRoles? }) — redact (or tokenize via @agentskit/core/security) string content fields in the AgentEvent stream (llm:end.content, tool:start.args, tool:end.result, agent:delegate:end.result, error.message) before they hit the underlying sink. Numeric / structural fields pass through unchanged so dashboards stay correct.

#Local trace viewer

  • createFileTraceSink(dir), buildTraceReport, renderTraceViewerHtml. See Trace viewer.

#Devtools server

  • createDevtoolsServer, toSseFrame. See Devtools server.
  • createTopologyGraph — live multi-agent topology graph for the devtools UI.
  • createControlSurface — production pause / step / replay control surface.

#SLO

  • sloObserver(targets?), DEFAULT_SLO_TARGETS — emit SLO breach events from latency / error / cost windows.

#Signed audit log

  • createSignedAuditLog, createInMemoryAuditStore. Hash-chain + HMAC. See Audit log.
  • appendPiiAuditEvents(log, { actor, action, hits, subjectId?, reason? }) — append one signed entry per PII redaction hit to an existing SignedAuditLog. action is pii:redact, pii:reveal, or pii:reveal-denied; each payload records rule id, counts, and match offset/length only (no raw spans), for tamper-evident audit evidence alongside the hash chain.

#Minimal example

import { consoleLogger, costGuard } from '@agentskit/observability'
import { createRuntime } from '@agentskit/runtime'

const runtime = createRuntime({
  adapter,
  observers: [consoleLogger(), costGuard({ maxUsd: 0.5 })],
})

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page