๐ Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/ai-agents/resilience/agent_resilience
Agent Resilience Policies Lab for C# .NET Applications
๐ฏ Purpose of the Demo
An interactive console app that demonstrates the four core resilience policies on a controllable flaky operation. Pick a policy, choose the failures-before-success profile, watch the policy behave. The same policies wrap real agent calls in production via AgentBuilder.WithFilters(...) and middleware.
No model is loaded; the demo focuses on policy mechanics.
๐ฅ Industry Target Audience
- Production teams hardening agent pipelines for real traffic.
- SRE / ops: understand state transitions before they ship.
- App developers learning the declarative resilience surface area.
- Architects picking the right policy or combination for a workflow.
๐ Problem Solved
Production agents fail under load. Retry covers transient errors. Circuit-breaker stops the bleed when a downstream is dead. Fallback returns a safe default. Composite chains them. The lab makes each behavior visible on a known-failure profile, so you can pick the right combination for your code path.
๐ป Application Overview
Interactive menu (no command-line arguments) with five modes:
| Mode | What it does |
|---|---|
| Retry | Run RetryPolicy with exponential backoff + jitter; pick failures-before-success interactively. |
| Breaker | Run CircuitBreakerPolicy against an always-failing operation; watch state transitions. |
| Fallback | Run FallbackPolicy<T> with a default return value. |
| Composite | Run CompositePolicy wrapping Retry + Fallback. |
| All | Run every demo back-to-back. |
| Quit | Exit. |
โจ Key Features
RetryPolicywithWithExponentialBackoff,WithJitter,OnRetry.CircuitBreakerPolicywithOnStateChange.FallbackPolicy<T>withshouldHandlepredicate.CompositePolicychained viaWrap(...).
๐ง Model
- None. No inference is required; the demo is pure policy mechanics.
๐ ๏ธ Getting Started
๐ Prerequisites
- .NET 8.0 or later
โถ๏ธ Running the Application
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/ai-agents/resilience/agent_resilience
dotnet run
Pick a policy from the menu.