Polly

Resilience and transient fault handling library for .NET — implements retry, circuit breaker, timeout, rate limiting, fallback, and hedging patterns. Polly v8 (via Microsoft.Extensions.Resilience): ResiliencePipelineBuilder<HttpResponseMessage>().AddRetry(new RetryStrategyOptions { MaxRetryAttempts = 3, BackoffType = DelayBackoffType.Exponential }).AddCircuitBreaker().AddTimeout(TimeSpan.FromSeconds(30)).Build(). AddResilienceHandler in IHttpClientBuilder for HttpClient integration. Handles transient failures in agent service-to-service calls, LLM API calls (rate limits, timeouts), and database operations. Policies chain into pipeline executing from outer to inner.

Evaluated Mar 07, 2026 (0d ago) v8.x
Homepage ↗ Repo ↗ Developer Tools dotnet csharp resilience retry circuit-breaker timeout rate-limiting fallback
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
89
/ 100
Is it safe for agents?
⚡ Reliability
88
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
85
Auth Simplicity
95
Rate Limits
90

🔒 Security

TLS Enforcement
92
Auth Strength
88
Scope Granularity
85
Dep. Hygiene
90
Secret Handling
90

Polly retry can amplify security issues — retrying agent auth failures wastes LLM API rate limit; configure ShouldHandle to exclude 401/403 responses from retry. Circuit breaker prevents agent service from hammering failing endpoints (DoS protection). Ensure retry budget accounts for LLM API rate limits to avoid auto-banning agent API keys.

⚡ Reliability

Uptime/SLA
92
Version Stability
85
Breaking Changes
78
Error Recovery
95
AF Security Reliability

Best When

Your .NET agent service makes external calls (LLM APIs, tool APIs, databases) that experience transient failures — Polly makes your agent resilient to temporary failures with minimal code changes.

Avoid When

Your calls are to local in-process dependencies, you need saga compensation, or your 'failures' are business logic errors that shouldn't be retried.

Use Cases

  • Retry agent LLM API calls on transient failures — ResiliencePipeline with AddRetry retries OpenAI/Anthropic calls on 429 (rate limit) and 503 (service unavailable) with exponential backoff; prevents agent failures from temporary LLM service blips
  • Circuit breaker for agent external tool calls — AddCircuitBreaker opens after 5 failures in 30 seconds, preventing cascading failures when agent tool API is down; half-open probing resumes calls after recovery window
  • Timeout protection for agent API calls — AddTimeout(TimeSpan.FromSeconds(10)) limits agent tool call execution time; prevents agent from hanging indefinitely on slow external services
  • HttpClient resilience pipeline for agent services — builder.AddHttpClient<IAgentApiClient, AgentApiClient>().AddResilienceHandler('agent-api', builder => { builder.AddRetry(...).AddCircuitBreaker(...) }) applies resilience to all agent HTTP calls
  • Rate limiting outbound agent LLM requests — AddRateLimiter(new SlidingWindowRateLimiter(options)) controls agent request rate to LLM API to stay within provider rate limits and prevent 429 errors

Not For

  • Inbound rate limiting for agent APIs — Polly limits outbound calls; for limiting incoming agent API requests from clients, use ASP.NET Core rate limiting middleware or API gateway
  • Saga compensation — Polly handles transient failures with retry/fallback; for complex agent workflow compensation (undo completed steps on failure), use Temporal or MassTransit Sagas
  • Infinite retry loops — Polly retry must have MaxRetryAttempts; unbounded retry on non-transient errors causes infinite loops; always configure max attempts and handle non-retryable exceptions

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Resilience library — no auth concepts. Handles retry/circuit breaker for HTTP calls that already have auth configured.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Polly is BSD-3 licensed, maintained by App-vNext. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Partial
Retry Guidance
Documented

Known Gotchas

  • Polly v8 is a breaking change from v7 — Polly 8 renamed to Microsoft.Extensions.Resilience and changed API entirely (PolicyWrap → ResiliencePipeline, Execute → ExecuteAsync); agent projects upgrading must rewrite all Policy.Handle<>().Retry() calls; v7 and v8 are not compatible in same registration approach
  • Retry non-idempotent agent operations causes data duplication — retrying POST /agents without idempotency key creates duplicate agents on each retry; Polly retries are transparent to business logic; add idempotency key header and handle 409 Conflict as retry-safe for agent creation endpoints
  • Circuit breaker is per-ResiliencePipeline instance — each agent client using separate ResiliencePipeline has isolated circuit breaker; all agent API calls should share same ResiliencePipeline instance via DI; separate instances don't share circuit state and each opens independently causing partial protection
  • jitter required for thundering herd on retry — ExponentialBackoff without jitter causes all failed agent instances to retry simultaneously after identical delay; AddRetry with UseJitter = true spreads retry attempts; critical for agent services with multiple instances hitting shared LLM API under load
  • ShouldHandle must explicitly include exception types — by default Polly v8 handles no exceptions; must configure ShouldHandle: new PredicateBuilder().Handle<HttpRequestException>().HandleResult(r => r.StatusCode == HttpStatusCode.TooManyRequests) for agent LLM retry; unspecified exception types are not retried even with retry policy
  • Timeout cancels via CancellationToken not exception — Polly timeout cancels operation via CancellationToken passed to agent handler; handler must observe CancellationToken for timeout to work; synchronous agent code ignoring cancellation token continues past timeout and TimeoutRejectedException is thrown after handler returns

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for Polly.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-07.

6470
Packages Evaluated
26150
Need Evaluation
173
Need Re-evaluation
Community Powered