Solutions · AI agents · Observability

Trace every token, tool, and plan.

Production agents are distributed systems. They invoke tools, delegate to workers, run planning loops, and stream tokens. Without tracing, debugging looks like reading a transcript and guessing. LM-Kit emits OpenTelemetry spans following the GenAI semantic conventions for agents, tools, planning steps, delegations, and orchestration nodes. Plug into Application Insights, Jaeger, Honeycomb, or any OTLP-compatible backend.

OpenTelemetry GenAI semconv ActivitySource Six span kinds

Agent spans

Whole-execution span with iteration count, tokens used, status.

Tool spans

One span per tool invocation with arguments and result.

Planning + delegation

Trace ReAct steps and supervisor delegations across workers.

Why agent tracing matters

Logs do not tell the whole story.

A failing agent might call three tools, delegate to a worker, retry once, stream half a response, and abort. Logs show fragments. Traces show the tree. The difference between a five-minute fix and a five-day investigation is whether you can see the tree.

Six span kinds

SpanKind distinguishes Agent, Tool, Planning, Delegation, Orchestration, Inference. Filter, group, alert per kind.

GenAI semconv

Tags follow the OpenTelemetry GenAI semantic conventions: model name, prompt tokens, completion tokens, tool name, latency. Backends recognise and aggregate them automatically.

ActivitySource

AgentDiagnostics.ActivitySource integrates with .NET's native diagnostics. Use existing OTel exporters; no custom plumbing.

Token-level events

Streaming runs emit token-level events you can sample. Spot which tokens were thinking, which were content, which triggered tool calls.

In-memory tracer for tests

InMemoryTracer captures spans without an external backend. Perfect for unit tests asserting an agent took the expected path.

Custom exporters

Implement ITraceExporter for proprietary backends. The pipeline is identical to mainstream observability: pluggable, tested, batched.

Wiring it up

Three lines, full visibility.

Subscribe an ActivityListener to AgentDiagnostics.ActivitySource or, in ASP.NET Core, register OTel with the source name. Done. Every agent run produces a span tree with parent/child relationships intact.

Register the agent activity source with OpenTelemetry to stream spans to Jaeger, Honeycomb, or the console.

OtelWiring.cs
using OpenTelemetry.Trace;
using LMKit.Agents.Observability;

// Standard OTel registration. AgentDiagnostics.SourceName is the source.
builder.Services.AddOpenTelemetry()
    .WithTracing(tp => tp
        .AddSource(AgentDiagnostics.SourceName)
        .AddOtlpExporter()                                // Jaeger, Honeycomb, etc.
        .AddConsoleExporter());                           // or write spans to console

// That is it. Every agent run, tool call, plan step, and delegation now traces.
var result = await agent.RunAsync("Diagnose pipeline failure in build #4321");
Versus the alternatives

Most agent frameworks treat tracing as an afterthought.

LangSmith / LangFuse

Excellent products, but tied to LangChain runs and require a separate SaaS. Local agents and offline workloads do not fit naturally.

Semantic Kernel telemetry

Basic telemetry hooks, but no GenAI semantic conventions and no agent-specific span kinds. You build the cross-agent picture yourself.

LM-Kit Observability

Native ActivitySource, GenAI semconv, six span kinds, in-memory tracer for tests, plugs into any OTel backend without leaving your network.

See the tree. Fix the bug.

Get Community Edition Download