Class AgentHealthCheck
- Namespace
- LMKit.Agents.Resilience
- Assembly
- LM-Kit.NET.dll
Monitors agent health and provides health check capabilities.
Tracks success rates, latency, and circuit breaker states to determine overall agent health.
public sealed class AgentHealthCheck
- Inheritance
-
AgentHealthCheck
- Inherited Members
Examples
var healthCheck = new AgentHealthCheck(agent)
.WithSuccessRateThreshold(0.9)
.WithLatencyThreshold(TimeSpan.FromSeconds(5));
var status = await healthCheck.CheckAsync();
Console.WriteLine($"Status: {status.Status}, Success Rate: {status.SuccessRate:P0}");
Constructors
- AgentHealthCheck(Agent)
Initializes a new instance of the AgentHealthCheck class.
Properties
- Agent
Gets the agent being monitored.
- CircuitBreaker
Gets or sets the circuit breaker to monitor.
Methods
- CheckAsync(CancellationToken)
Performs an active health check by executing a test prompt.
- GetStatus()
Gets the current health status without performing an active check.
- RecordFailure(TimeSpan, Exception)
Records a failed execution.
- RecordSuccess(TimeSpan)
Records a successful execution.
- Reset()
Clears all recorded samples.
- WithHealthCheckPrompt(string)
Sets the prompt used for active health checks.
- WithLatencyThreshold(TimeSpan)
Sets the latency threshold for healthy status.
- WithMaxSamples(int)
Sets the maximum number of samples to retain.
- WithSampleWindow(TimeSpan)
Sets the sample window for calculating metrics.
- WithSuccessRateThreshold(double)
Sets the success rate threshold for healthy status.