Round #857
11 May 2026, 09:48· csharp· Meta-Llama-3.3-70B-Instruct· r15-firing-v3
- Complexity
- band 1
- ZP / UO / OBS
- 2 / 7 / 2
- Journey weight
- 617
- Lightshift ΔL
- +0.25
Prompt
Build a Polly v8 ResiliencePipeline that retries on transient HTTP errors three times with exponential backoff, then trips a circuit breaker after five consecutive failures.
Zero-point index (what the engine surfaced)
ZPI-ZPI-0014 | 2026-05-11T09:48:25Z
Build a Polly v8 ResiliencePipeline that retries on transient HTTP errors three times with exponential backoff, then trips a circuit breaker after five consecutive failures.
ZERO POINT — 2 entries (structural invariants)
● hsl(296.42, 100%, 50%) ResiliencePipeline [contract]
● hsl(211.57, 100%, 50%) ResiliencePipelineBuilder [contract]
UNOBSERVED — 7 entries (implied truths)
○ hsl(27.69, 100%, 50%) async [feature]
○ hsl(9.23, 100%, 50%) interface [feature]
○ hsl(77.54, 100%, 42%) Routing middleware [function]
○ hsl(83.08, 100%, 42%) ILogger of T injection [function]
○ hsl(31.38, 100%, 42%) Scoped registration [function]
○ hsl(49.23, 100%, 50%) try [feature]
○ hsl(144.00, 100%, 42%) Connection resilience [function]
OBSERVED — 2 entries (explicit in request)
◉ hsl(73.85, 100%, 15%) on [feature]
◉ hsl(98.46, 100%, 50%) with [feature]
COMPLEXITY │ 11 entries │ spread: 135° │ band: MEDIUM
Baseline response (no ZPI)
Here's an example of how you can build a Polly v8 ResiliencePipeline in C# that retries on transient HTTP errors three times with exponential backoff, then trips a circuit breaker after five consecutive failures:
```csharp
using Polly;
using Polly.CircuitBreaker;
using Polly.Retry;
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class ResiliencePipeline
{
private readonly HttpClient _httpClient;
public ResiliencePipeline(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<string> ExecuteResilientRequestAsync(string url)
{
// Define the retry policy with exponential backoff
var retryPolicy = Policy.Handle<HttpRequestException>(ex => IsTransientHttpError(ex))
.OrResult<HttpResponseMessage>(response => IsTransientHttpError(response))
.WaitAndRetryAsync(
retryCount: 3,
retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
(exception, timeSpan, retryCount, context) =>
{
Console.WriteLine($"Retry {retryCount} after {timeSpan.TotalSeconds} seconds. Exception: {exception.Message}");
});
// Define the circuit breaker policy
var circuitBreakerPolicy = Policy.Handle<HttpRequestException>(ex => IsTransientHttpError(ex))
.OrResult<HttpResponseMessage>(response => IsTransientHttpError(response))
.CircuitBreakerAsync(
exceptionsAllowedBeforeBreaking: 5,
durationOfBreak: TimeSpan.FromMinutes(1),
onBreak: (exception, timeSpan, context) =>
{
Console.WriteLine($"Circuit broken. Exception: {exception.Message}. Duration of break: {timeSpan.TotalMinutes} minutes");
},
onReset: (context) =>
{
Console.WriteLine("Circuit reset");
});
// Combine the retry and circuit breaker policies
var resiliencePipeline = Policy.WrapAsync(retryPolicy, circuitBreakerPolicy);
// Execute the resilient request
return await resiliencePipeline.ExecuteAsync(async () =>
{
var response = await _httpClient.GetAsync(url);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
});
}
private bool IsTransientHttpError(HttpRequestException ex)
{
// Check if the exception is a transient HTTP error
if (ex.InnerException is SocketException socketException)
{
return socketException.SocketErrorCode == SocketError.ConnectionRefused ||
socketException.SocketErrorCode == SocketError.TimedOut ||
socketException.SocketErrorCode == SocketError.HostNotFound;
}
return false;
}
private bool IsTransientHttpError(HttpResponseMessage response)
{
// Check if the response is a transient HTTP error
return response.StatusCode == System.Net.HttpStatusCode.GatewayTimeout ||
response.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable ||
response.StatusCode == System.Net.HttpStatusCode.BadGateway;
}
}
```
In this example, the `ResiliencePipeline` class defines a pipeline that combines a retry policy with a circuit breaker policy. The retry policy retries on transient HTTP errors three times with exponential backoff, while the circuit breaker policy trips after five consecutive failures and remains broken for one minute.
You can use the `ResiliencePipeline` class as follows:
```csharp
var httpClient = new HttpClient();
var resiliencePipeline = new ResiliencePipeline(httpClient);
var url = "https://example.com";
var response = await resiliencePipeline.ExecuteResilientRequestAsync(url);
Console.WriteLine(response);
```
This code will execute a GET request to the specified URL with the resilience pipeline, retrying on transient HTTP errors and tripping the circuit breaker after five consecutive failures.
Enhanced response (with ZPI)
```csharp
using Polly;
using Polly.Extensions.Http;
public class ResiliencePipelineBuilder
{
public static IAsyncPolicy<HttpResponseMessage> BuildResiliencePipeline()
{
var retryPolicy = Policy.Handle<HttpRequestException>(ex => ex.InnerException is SocketException)
.OrResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.ServiceUnavailable)
.WaitAndRetryAsync(
retryCount: 3,
retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
(exception, span) => Console.WriteLine($"Retrying in {span.TotalSeconds} seconds...")
);
var circuitBreakerPolicy = Policy.Handle<HttpRequestException>(ex => ex.InnerException is SocketException)
.OrResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.ServiceUnavailable)
.CircuitBreakerAsync(
exceptionsAllowedBeforeBreaking: 5,
durationOfBreak: TimeSpan.FromMinutes(1),
onBreak: (ex, ts) => Console.WriteLine($"Circuit broken for {ts.TotalMinutes} minutes..."),
onReset: () => Console.WriteLine("Circuit reset.")
);
return Policy.WrapAsync(retryPolicy, circuitBreakerPolicy);
}
}
```
This implementation uses Polly's `Policy.Handle` to catch transient HTTP errors and `WaitAndRetryAsync` to implement exponential backoff. The `CircuitBreakerAsync` policy is used to trip the circuit after five consecutive failures. The `Policy.WrapAsync` method is used to combine the retry and circuit breaker policies into a single resilience pipeline.
Grader chain
Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.
V1samba/Meta-Llama-3.3-70B-Instruct
BetterV4qwen2.5-coder-3b-instruct
BetterV5openrouter/qwen/qwen3-235b-a22b-2507
BetterV7qwen2.5-coder-7b-instruct
BetterV8openai/gpt-4.1
SameV9anthropic/claude-opus-4-7
WorseV12openai/gpt-4o
BetterComments
Our grader said what it said. What do you say? Comment as a guest below.
No comments yet. Be the first to say what you make of this round.