Table of Contents

Class AgentDiagnostics

Namespace
LMKit.Agents.Observability
Assembly
LM-Kit.NET.dll

OpenTelemetry-compatible diagnostic source for the agent runtime.

Exposes a single ActivitySource named LMKit.Agents that the orchestration and execution layers use to emit distributed-trace activities. Consumers register the source with their tracer of choice (OpenTelemetry, .NET ActivityListener, Application Insights, etc.) to capture spans for orchestration runs, individual agent invocations, and delegations.

This is independent of the in-tree IAgentTracer system: agent tracers receive structured per-iteration events tied to the planning loop, while ActivitySource emits coarser distributed-trace spans suitable for cross-process correlation.

public static class AgentDiagnostics
Inheritance
AgentDiagnostics
Inherited Members

Examples

Capturing agent activities with a minimal ActivityListener:

using System.Diagnostics;
using LMKit.Agents.Observability;

using var listener = new ActivityListener { ShouldListenTo = src => src.Name == AgentDiagnostics.SourceName, Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData, ActivityStopped = a => { Console.WriteLine($"{a.OperationName} ({a.Duration.TotalMilliseconds:F0} ms) " + $"agent={a.GetTagItem("agent.name")} status={a.Status}"); } }; ActivitySource.AddActivityListener(listener);

// Now any agent or orchestrator execution emits activities to the listener. var orchestrator = new PipelineOrchestrator() .AddStage("research", researcher) .AddStage("write", writer); await orchestrator.ExecuteAsync("Topic: edge AI");

Wiring the source into OpenTelemetry:

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

using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource(AgentDiagnostics.SourceName) .AddConsoleExporter() .Build();

Fields

ActivitySource

The shared ActivitySource used by the agent runtime to emit distributed-trace activities.

SourceName

The well-known name of the agent ActivitySource. Pass this to OpenTelemetry.Trace.TracerProviderBuilder.AddSource or ShouldListenTo to capture agent spans.

TagAgentName

Tag name: the agent's persona / display name.

TagDelegationFrom

Tag name: the source agent in a delegation.

TagDelegationTo

Tag name: the target agent in a delegation.

TagInferenceCount

Tag name: the inference count consumed by an agent execution.

TagOrchestratorName

Tag name: the orchestrator's Name.

TagPlanningStrategy

Tag name: the agent's planning strategy (PlanningStrategy).

TagStatus

Tag name: the final AgentExecutionStatus.

TagStep

Tag name: the 1-based step number within an orchestration.

Share