For about a month now, every week’s reading has had at least one “decision model” item in it. Jev started it, OpenAI shipped Decisions, Parallel shipped a web-grounded one, Hume opened a waitlist for an audio one. Most of what I read is either launch coverage or Python.
Then Mikhail Petrusheuski published “OpenAI Decisions is now a typed .NET routing primitive”, with a small sample repo next to it. It’s the first piece I’ve seen that treats Decisions the way a .NET developer would actually meet it: a NuGet package, an experimental attribute you have to suppress, a client type, and a probability you route on.
I like the piece. I also came away with a stronger opinion than I expected: the shape he shows is exactly right, and that’s the reason I don’t want my application code to depend on it directly. This post is about that gap. What’s good about a typed decision call, why I’d put my own interface in front of it, and the local fallback I’d keep behind it even if the hosted API turns out to be great.
Nothing here comes from running anything. The numbers are other people’s, labelled with whose they are. The code is how I would wire it.
The setup in his article is one package:
dotnet add package OpenAI --version 2.15.0
The Decisions surface in that package is marked experimental, so you suppress the diagnostic to use it:
#pragma warning disable OPENAI001
The types he uses are DecisionsClient, DecisionCreationOptions, DecisionsPredicateQuestion, the CreateDecisionAsync method, and DecisionsPredicateAnswer.Probability for the number you route on. The model is gpt-6-luna, which is the only model the Decisions endpoint supports right now.
His sample routes incidents. The routing policy lives in the application, not in the model:
+-----------------------------------+-------------------+| Result | Route |+-----------------------------------+-------------------+| probability >= 0.85 | urgent-response || 0.35 <= probability < 0.85 | human-review || probability < 0.35 | normal-queue || refusal or failed call | human-review |+-----------------------------------+-------------------+Source: Petrusheuski's article and sample repo README. He calls the thresholds illustrative.
Three things in his handling I’d keep verbatim in spirit:
The vendor claims, as he labels them:
Those are OpenAI’s numbers. He doesn’t present them as his measurements and neither will I.
Two honesty notes before I build on any of this. His article carries a “Drafted with AI assistance” disclosure, and his README says the sample “hasn’t been run against the live API yet.” I haven’t been able to check the package version or the type names anywhere outside his article, because I don’t have a .NET build of the 2.15.0 surface in front of me. So in the code below, everything that touches the OpenAI types is marked as “check this against the package”, and I’ve kept it to one small class so that being wrong costs one file.
For anyone who skipped the last two weeks: OpenAI previewed Decisions at DevDay on 29 September and opened it as a public beta on 6 October. It’s its own endpoint, POST /v1/decisions, not a mode on the Responses API. There are three question types: predicate (a probability that a statement is true), choice (one option from a fixed list, with probabilities), and a ranked type over ordered levels, which some coverage and the Azure docs call score.
Since then it has spread. Classmethod’s write-up from 25 October says OpenAI moved Decisions to general availability on 22 October and that it landed in Azure OpenAI on Microsoft Foundry the same day, at /openai/v1/decisions on your resource, gpt-6-luna only, rolling out to regions where that model is available, with East US 2 not included. I haven't found OpenAI's own GA changelog entry, so treat the GA date as Classmethod's report. The .NET surface being behind OPENAI001 is a separate thing: an experimental attribute in the SDK can outlive a GA endpoint.
And it’s one product in a crowded category now:
That last point is the whole setup for this article. Four vendors, four request shapes, four definitions of “probability”, and none of them independently compared on the kind of question I’d actually ask. That’s a category where I want the seam in my code to be mine.
What I like about a decision call is not the speed or the price. It’s that it forces the right shape on the code around it:
That’s a great contract. The problem is that if the contract is DecisionsPredicateAnswer.Probability, the contract belongs to an experimental type in one vendor's SDK, and every call site in my app now knows about it. When the type is renamed (it's experimental, that's allowed), or when I want to try Jev or a local model on the same question, I'm editing call sites instead of swapping an implementation.
So the plan is boring on purpose:
I’m not the only one who thinks this. While reading around I found Minos.NET, a community library with a provider-neutral IDecisionClient and separate packages for TypeSafe's protocol, OpenAI Decisions and Microsoft.Extensions.AI. Its OpenAI package says it is "not yet tested against the live API", and I haven't used it, so this isn't a recommendation. It's just a sign that the seam is in the right place. If you'd rather not own the code, a library like that is the obvious alternative. I'd still own the result type and the band, because those encode my policy.
C# doesn’t have discriminated unions yet, so I use a closed record hierarchy. A switch over it is exhaustive enough in practice, and every case carries what that case actually knows.
// DecisionContract.csnamespace Routing.Decisions;/// <summary>What a decision call produced. Closed set: add a case here, not a flag.</summary>public abstract record DecisionResult(string Source){ /// <summary>The probability the statement is true, when the source gave one.</summary> public virtual double? Probability => null; public sealed record Yes(double P, string From) : DecisionResult(From) { public override double? Probability => P; } public sealed record No(double P, string From) : DecisionResult(From) { public override double? Probability => P; } /// <summary>A probability came back, but it fell inside the band.</summary> public sealed record Uncertain(double P, string From) : DecisionResult(From) { public override double? Probability => P; } /// <summary>The model answered but would not decide. Not an outage.</summary> public sealed record Refused(string Reason, string From) : DecisionResult(From); /// <summary>No usable answer: transport error, timeout, bad payload.</summary> public sealed record Failed(string Error, string From) : DecisionResult(From);}public interface IDecisionRouter{ /// <param name="question">A statement the model judges as true or false.</param> /// <param name="input">The content the statement is about.</param> Task<DecisionResult> DecideAsync(string question, string input, CancellationToken ct = default);}
The band is the other half of the contract. Two thresholds, validated once, applied the same way everywhere:
// DecisionBand.csnamespace Routing.Decisions;/// <summary>/// p >= YesAtOrAbove is Yes, p < NoBelow is No, anything between is Uncertain./// The defaults are Petrusheuski's illustrative 0.85 / 0.35, not tuned values./// </summary>public sealed record DecisionBand{ public double YesAtOrAbove { get; } public double NoBelow { get; } public DecisionBand(double yesAtOrAbove = 0.85, double noBelow = 0.35) { if (noBelow is < 0 or > 1 || yesAtOrAbove is < 0 or > 1) throw new ArgumentOutOfRangeException(nameof(yesAtOrAbove), "Thresholds must be within [0, 1]."); if (noBelow >= yesAtOrAbove) throw new ArgumentException("NoBelow must be lower than YesAtOrAbove, or there is no band."); YesAtOrAbove = yesAtOrAbove; NoBelow = noBelow; } public DecisionResult Classify(double p, string source) => p >= YesAtOrAbove ? new DecisionResult.Yes(p, source) : p < NoBelow ? new DecisionResult.No(p, source) : new DecisionResult.Uncertain(p, source);}
Why a band and not a single cut-off at 0.5? Because a single threshold silently decides every case near the line, and near the line is exactly where a model’s number is least trustworthy. A band turns “I don’t know” into a first-class outcome with somewhere to go. It costs reviewer time, and that’s the trade I’d rather make visibly than hide.
This is the class I’m least sure about, so it’s also the smallest. The type and member names are the ones Petrusheuski’s article uses. I have not compiled this against OpenAI 2.15.0. Before you use it, open the package’s API surface and check every line marked CHECK.
<!-- Routing.Decisions.OpenAI.csproj (relevant part) --><ItemGroup> <PackageReference Include="OpenAI" Version="2.15.0" /></ItemGroup>
// OpenAIDecisionRouter.cs// EXPERIMENTAL: the OpenAI .NET Decisions surface is marked OPENAI001 and may change.// The type and member names below come from Mikhail Petrusheuski's article// ("OpenAI Decisions is now a typed .NET routing primitive") and have NOT been// verified against the OpenAI 2.15.0 package by me. Lines marked CHECK are the// places most likely to differ. Keep all OpenAI types inside this one file.#pragma warning disable OPENAI001using System.ClientModel;using OpenAI.Decisions; // CHECK: namespacenamespace Routing.Decisions.OpenAI;public sealed class OpenAIDecisionRouter : IDecisionRouter{ private const string Model = "gpt-6-luna"; // the only model the endpoint supports today private const string Key = "answer"; private readonly DecisionsClient _client; private readonly DecisionBand _band; public OpenAIDecisionRouter(string apiKey, DecisionBand band) { _client = new DecisionsClient(Model, apiKey); // CHECK: constructor shape _band = band; } public async Task<DecisionResult> DecideAsync(string question, string input, CancellationToken ct = default) { const string source = "openai-decisions/" + Model; try { var options = new DecisionCreationOptions(); // CHECK options.Questions.Add(Key, new DecisionsPredicateQuestion(question)); // CHECK: how questions are attached var result = await _client.CreateDecisionAsync(input, options, ct); // CHECK: parameter order // Anything that is not a readable predicate probability is treated as a refusal. // I am deliberately not guessing the name of a refusal field: whatever the package // exposes, "no probability came back" is the case the router has to handle. if (result.Value.Answers.TryGetValue(Key, out var raw) // CHECK: answers collection && raw is DecisionsPredicateAnswer predicate) { return _band.Classify(predicate.Probability, source); } return new DecisionResult.Refused("No predicate probability in the response.", source); } catch (OperationCanceledException) when (ct.IsCancellationRequested) { throw; // the caller cancelled: not a routing outcome } catch (ClientResultException ex) { return new DecisionResult.Failed($"HTTP {ex.Status}: {ex.Message}", source); } catch (Exception ex) { return new DecisionResult.Failed(ex.Message, source); } }}
ClientResultException comes from System.ClientModel, which is what the OpenAI .NET library uses for HTTP errors, so that part I'm comfortable with. The rest is his surface, quarantined.
One design note: the band is applied here, inside the implementation, so every router returns Yes, No or Uncertain on the same rule. The calling code never sees a raw probability unless it asks for Probability for logging.
This is the fallback, and also the thing I’d use in development so I’m not paying per test run. It goes through IChatClient from Microsoft.Extensions.AI, with OllamaSharp as the Ollama client, and asks for structured output against a JSON schema.
Set up Ollama either natively:
# Ollama installed from ollama.comollama pull qwen2.5:7bollama serve # skip if the desktop app is already running
or in Docker:
docker run -d --name ollama -p 11434:11434 -v ollama:/root/.ollama ollama/ollamadocker exec ollama ollama pull qwen2.5:7b
Packages:
dotnet add package Microsoft.Extensions.AIdotnet add package OllamaSharp
The schema is the whole contract with the local model:
{ "type": "object", "properties": { "answer": { "type": "string", "enum": ["yes", "no"] }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 } }, "required": ["answer", "confidence"], "additionalProperties": false}
And the router:
// LocalDecisionRouter.csusing System.Text.Json;using Microsoft.Extensions.AI;namespace Routing.Decisions.Local;/// <summary>/// Decision router over any IChatClient (here: Ollama) with JSON-schema structured output./// IMPORTANT: "confidence" is a number the model writes down, not a calibrated probability./// Local models asked for a confidence tend to cluster on round values (0.9, 0.95)./// Give this router a wider band than a hosted decision model, and never compare its/// numbers to another router's numbers as if they were on the same scale./// </summary>public sealed class LocalDecisionRouter : IDecisionRouter{ private static readonly JsonElement Schema = JsonDocument.Parse(""" { "type": "object", "properties": { "answer": { "type": "string", "enum": ["yes", "no"] }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 } }, "required": ["answer", "confidence"], "additionalProperties": false } """).RootElement.Clone(); private readonly IChatClient _chat; private readonly DecisionBand _band; private readonly string _source; public LocalDecisionRouter(IChatClient chat, DecisionBand band, string modelName) { _chat = chat; _band = band; _source = "local/" + modelName; } public async Task<DecisionResult> DecideAsync(string question, string input, CancellationToken ct = default) { var messages = new List<ChatMessage> { new(ChatRole.System, "You judge whether a statement is true for the given input. " + "Reply only with JSON matching the schema. " + "confidence is how sure you are that your answer is correct, from 0 to 1."), new(ChatRole.User, $"Statement: {question}\n\nInput:\n{input}") }; var options = new ChatOptions { ResponseFormat = ChatResponseFormat.ForJsonSchema(Schema, "decision"), Temperature = 0 }; try { var response = await _chat.GetResponseAsync(messages, options, ct); var parsed = JsonSerializer.Deserialize<LocalAnswer>(response.Text, JsonOptions); if (parsed is null || parsed.Answer is not ("yes" or "no") || parsed.Confidence is < 0 or > 1) return new DecisionResult.Failed($"Unexpected payload: {response.Text}", _source); // Convert "answer + confidence in the answer" into "probability the statement is true". var pTrue = parsed.Answer == "yes" ? parsed.Confidence : 1 - parsed.Confidence; return _band.Classify(pTrue, _source); } catch (OperationCanceledException) when (ct.IsCancellationRequested) { throw; } catch (Exception ex) { return new DecisionResult.Failed(ex.Message, _source); } } private static readonly JsonSerializerOptions JsonOptions = new() { PropertyNameCaseInsensitive = true }; private sealed record LocalAnswer(string Answer, double Confidence);}
Wiring it to Ollama is one line, because OllamaSharp’s OllamaApiClient implements IChatClient:
using OllamaSharp;IChatClient ollama = new OllamaApiClient(new Uri("http://localhost:11434"), "qwen2.5:7b");
Notice what this router can’t do: refuse. The schema forces a yes or a no, so a local model that “doesn’t want to answer” will still pick one and attach a number. That’s a real difference from the hosted API, and it’s one more reason the local band should be wider. A model that can’t say “I won’t” needs more room to say “I’m not sure”.
This is where the contract earns its keep. The policy doesn’t know which vendor answered. It knows five cases.
// RoutingPolicy.csusing System.Threading.Channels;namespace Routing.Decisions;public enum Route { AutoYes, AutoNo, HumanQueue }public sealed record HumanReviewItem(string Question, string Input, DecisionResult Result, DateTimeOffset QueuedAt);public interface IHumanQueue{ ValueTask EnqueueAsync(HumanReviewItem item, CancellationToken ct = default);}/// <summary>In-memory queue for development. Use a durable queue in production.</summary>public sealed class ChannelHumanQueue : IHumanQueue{ private readonly Channel<HumanReviewItem> _channel = Channel.CreateUnbounded<HumanReviewItem>(); public ChannelReader<HumanReviewItem> Reader => _channel.Reader; public ValueTask EnqueueAsync(HumanReviewItem item, CancellationToken ct = default) => _channel.Writer.WriteAsync(item, ct);}public sealed class RoutingPolicy(IDecisionRouter router, IHumanQueue humans, TimeProvider clock){ public async Task<Route> RouteAsync(string question, string input, CancellationToken ct = default) { var result = await router.DecideAsync(question, input, ct); switch (result) { case DecisionResult.Yes: return Route.AutoYes; case DecisionResult.No: return Route.AutoNo; case DecisionResult.Uncertain: case DecisionResult.Refused: case DecisionResult.Failed: await humans.EnqueueAsync(new HumanReviewItem(question, input, result, clock.GetUtcNow()), ct); return Route.HumanQueue; default: throw new InvalidOperationException($"Unhandled decision result: {result.GetType().Name}"); } }}
Uncertain, Refused and Failed all land in the same queue, but they stay distinguishable in the HumanReviewItem. That matters later. If the queue fills up with Failed, I have an outage. If it fills up with Uncertain, my band is too wide or my question is bad. If it fills up with Refused, my question is probably asking something the vendor doesn't want to answer, and that's a product conversation, not a tuning one.
Here’s the decision behind the title. I’d put the local router behind the hosted one, but only for one case.
// FallbackDecisionRouter.csnamespace Routing.Decisions;/// <summary>/// Tries the primary router. Only a Failed result falls through to the secondary./// Refused does NOT fall through: a refusal is an answer about the question, and/// asking a second model until one agrees is how you launder a "no" into a "yes"./// Uncertain does NOT fall through either: shopping for a confident answer/// defeats the point of having a band./// </summary>public sealed class FallbackDecisionRouter(IDecisionRouter primary, IDecisionRouter secondary) : IDecisionRouter{ public async Task<DecisionResult> DecideAsync(string question, string input, CancellationToken ct = default) { var first = await primary.DecideAsync(question, input, ct); return first is DecisionResult.Failed ? await secondary.DecideAsync(question, input, ct) : first; }}
And composition, with a wider band on the local side:
// Program.cs (composition only)using Microsoft.Extensions.AI;using OllamaSharp;using Routing.Decisions;using Routing.Decisions.Local;using Routing.Decisions.OpenAI;var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("Set OPENAI_API_KEY.");// Hosted: Petrusheuski's illustrative band.var hosted = new OpenAIDecisionRouter(apiKey, new DecisionBand(yesAtOrAbove: 0.85, noBelow: 0.35));// Local: deliberately wider, because its confidence is self-reported, not calibrated.// These are my starting assumptions, not tuned values.IChatClient ollama = new OllamaApiClient(new Uri("http://localhost:11434"), "qwen2.5:7b");var local = new LocalDecisionRouter(ollama, new DecisionBand(yesAtOrAbove: 0.95, noBelow: 0.10), "qwen2.5:7b");var router = new FallbackDecisionRouter(hosted, local);var queue = new ChannelHumanQueue();var policy = new RoutingPolicy(router, queue, TimeProvider.System);var route = await policy.RouteAsync( question: "This incident report describes a customer-facing outage happening right now.", input: "Checkout returns 502 for all EU users since 14:05. Status page not updated yet.");Console.WriteLine(route);
Why keep the fallback at all, if the hosted API is good? Three reasons, none of them about accuracy:
I want to be strict here. Every cell is either from a named source or says “unknown”. Where something is true by construction (a model on your own machine keeps the data on your machine), I say so plainly.
+------------------+-------------------------------+-------------------------------+-------------------------------+| | Hosted OpenAI Decisions | Local LLM, structured output | Small fine-tuned classifier |+------------------+-------------------------------+-------------------------------+-------------------------------+| Cost model | $0.10 / M input tokens, | Your hardware; no per-call | Training plus hosting; || | output not charged [V] | fee | per-call cost unknown || | Input over 272K tokens billed | | || | at 2x; in-region +10% [N] | | |+------------------+-------------------------------+-------------------------------+-------------------------------+| Calibration | unknown (no independent | Not calibrated: confidence | unknown until measured on || | measurement found) | is self-reported | your own held-out labels |+------------------+-------------------------------+-------------------------------+-------------------------------+| Latency | "about 10x faster than the | unknown (depends on model | unknown || | Responses API" [V]; absolute: | and hardware) | || | unknown. Classmethod saw | | || | 1.4-2.0 s for 3 text calls, | | || | Japan to eastus [A] | | |+------------------+-------------------------------+-------------------------------+-------------------------------+| Data residency | In-region processing offered | Stays on the machine that | Wherever you host it || | at a surcharge [N]; Azure: | runs it | || | regions with gpt-6-luna, not | | || | East US 2 [A] | | |+------------------+-------------------------------+-------------------------------+-------------------------------+| Lock-in | One model (gpt-6-luna); .NET | Low: any IChatClient behind | Low on the vendor side; the || | surface experimental under | the same interface | labelled data is the asset || | OPENAI001 [P] | | |+------------------+-------------------------------+-------------------------------+-------------------------------+[V] vendor claim, as reported by Petrusheuski and launch coverage, unverified[N] newsletter or blog summary of OpenAI's guide (SmartScope), not checked against the guide by me[A] author-run by Classmethod on their own Azure resource, three calls, not a benchmark[P] Petrusheuski's article and sample README
The honest reading of that table: the hosted option is the only one with a published price, and nobody has a calibration number for any of them on my kind of question. Which brings me to the thing I’d actually want to know.
Is the probability stable across repeated calls?
If I send the same question and the same input to Decisions five times, do I get 0.84, 0.84, 0.84, 0.84, 0.84, or 0.79, 0.88, 0.84, 0.91, 0.80? I haven’t seen anyone publish that, for OpenAI Decisions or for the others, and I’m not going to guess.
It matters more than accuracy for one reason: thresholds. A threshold at 0.85 means something only if the number on either side of it is repeatable. If the same incident can come back as 0.83 on one call and 0.87 on the next, the routing decision for that incident is a coin flip that happens to be dressed up as a probability. A well-calibrated model can still do this, because calibration is about averages over many inputs, not about the same input twice.
That’s why I wouldn’t trust a single threshold until I knew the answer, and why the band is the default in the code above. A band absorbs jitter by design: anything that wobbles near the line goes to a person instead of flipping between two automatic routes. If it turns out the numbers are rock solid, I can narrow the band and save reviewer time. If they aren’t, the band was the thing that kept me from routing on noise.
If I were checking this myself, this is the probe I’d write. It doesn’t need to run in this article to be useful, it just needs to exist next to the router:
// StabilityProbe.csnamespace Routing.Decisions;public sealed record StabilitySample(string Question, string Input, IReadOnlyList<double> Probabilities){ public double Spread => Probabilities.Count == 0 ? 0 : Probabilities.Max() - Probabilities.Min(); /// <summary>True if repeated calls landed on both sides of a threshold.</summary> public bool StraddlesThreshold(double threshold) => Probabilities.Any(p => p >= threshold) && Probabilities.Any(p => p < threshold);}public static class StabilityProbe{ public static async Task<StabilitySample> SampleAsync( IDecisionRouter router, string question, string input, int repeats, CancellationToken ct = default) { ArgumentOutOfRangeException.ThrowIfLessThan(repeats, 2); var ps = new List<double>(repeats); for (var i = 0; i < repeats; i++) { var r = await router.DecideAsync(question, input, ct); if (r.Probability is double p) ps.Add(p); } return new StabilitySample(question, input, ps); }}
The two numbers I’d care about are Spread per input and how many inputs StraddlesThreshold at each edge of the band. If a meaningful share of real inputs straddles 0.85, a single cut-off at 0.85 is not a policy. It's a random number generator with a nice name.
I’d use OpenAI Decisions for routing. The typed question, the probability, the input-only pricing: that’s a good shape for a lot of the “is this urgent, which queue, does this need a person” calls that currently go through a generative model and a regex.
I just wouldn’t let my application code know that’s what it’s using. One interface. A result type with room for refusals and failures. Two thresholds in configuration. A human queue for everything in between. A local model behind it that only speaks when the hosted one can’t, with a wider band because its numbers mean less. And no single threshold until someone, ideally me on my own traffic, has shown the probability holds still.
Petrusheuski’s sample already gets the most important part right: the policy lives in the app, and a probability is not authorization. Owning the contract is just taking that one step further.
Sources
Tags: DotNet, CSharp, OpenAI, LLM, AI Agents, Software Architecture, Ollama, Microsoft Extensions AI, Artificial Intelligence, Decision Models
OpenAI Decisions in .NET, and the Local Fallback I Would Keep Anyway was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
原文来源:pub.towardsai.net