Class ResilienceContext
- Namespace
- LMKit.Agents.Resilience
- Assembly
- LM-Kit.NET.dll
Context shared across policy executions.
public sealed class ResilienceContext
- Inheritance
-
ResilienceContext
- Inherited Members
Examples
Tagging an operation and reading back the attempt count after a retry:
using LMKit.Agents.Resilience;
var ctx = new ResilienceContext { OperationName = "summarize-doc" };
var output = await retry.ExecuteAsync(
async (c, ct) => (await agent.RunAsync(input, ct)).Content,
ctx);
Console.WriteLine($"{ctx.OperationName} succeeded after {ctx.AttemptNumber} attempts " +
$"({ctx.Exceptions.Count} prior failures).");
Properties
- AttemptNumber
Gets or sets the current attempt number (1-based).
- Exceptions
Gets the exceptions that occurred during execution.
- this[string]
Gets custom state storage.
- LastException
Gets or sets the last exception that occurred.
- OperationName
Gets the operation name for logging.
- Succeeded
Gets or sets whether the operation succeeded.
- TotalAttempts
Gets the total number of attempts made.
Methods
- GetState<T>(string, T)
Gets a typed value from state.
- SetState<T>(string, T)
Sets a value in state.