Table of Contents

Class ResilientAgentExecutor

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

An agent executor that applies resilience policies to execution.

Wraps agent execution with retry, circuit breaker, timeout, and fallback policies for production reliability.

public sealed class ResilientAgentExecutor : IAgentExecutor, IDisposable
Inheritance
ResilientAgentExecutor
Implements
Inherited Members

Examples

var executor = new ResilientAgentExecutor()
    .WithRetry(3)
    .WithTimeout(TimeSpan.FromMinutes(2))
    .WithCircuitBreaker(5, TimeSpan.FromSeconds(30))
    .OnRetry((ex, attempt) => Console.WriteLine($"Retry {attempt}"));

var result = await executor.ExecuteAsync(agent, "Hello");

Constructors

ResilientAgentExecutor()

Initializes a new instance of the ResilientAgentExecutor class.

ResilientAgentExecutor(IResiliencePolicy)

Initializes a new instance with a custom policy.

Properties

CircuitBreaker

Gets the circuit breaker, if configured.

Policy

Gets the current resilience policy.

Methods

Dispose()

Disposes the executor.

Execute(Agent, string, CancellationToken)

Executes a single task synchronously with the specified agent.

ExecuteAsync(Agent, string, AgentExecutionOptions, CancellationToken)

Executes with additional options.

ExecuteAsync(Agent, string, CancellationToken)

Executes a single task with the specified agent.

OnCircuitStateChange(Action<CircuitState, CircuitState>)

Sets a callback for circuit breaker state changes.

OnRetry(Action<Exception, int>)

Sets a callback for retry events.

ResetCircuitBreaker()

Resets the circuit breaker if configured.

UsePolicy(IResiliencePolicy)

Sets a custom resilience policy, replacing any configured policies.

WithCircuitBreaker(int, TimeSpan?)

Configures circuit breaker behavior.

WithRetry(int, TimeSpan?, bool)

Configures retry behavior.

WithTimeout(TimeSpan)

Configures timeout behavior.