👉 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.