.NET
14 articles on .NET, each a problem from production engineering work and how it was solved.
-
Warming a Langfuse prompt cache at .NET startup for cold starts
A last-known-good prompt cache only covers outages that start after a pod is warm. Resolve every prompt in a hosted service at startup and log a census.
-
LiteLLM model aliases per use case to survive OpenAI model retirements
Call a LiteLLM alias named after the use case, not a raw model id, so a retired OpenAI model is swapped on the proxy without a deploy.
-
Task.WhenAll with Result types: catch one failed LLM call of two
Derive the run status from every call's outcome, not from whether output was written, or one failed call of two reports Success.
-
Return 400 for a missing enum in ASP.NET Core with required
Mark the enum property required: System.Text.Json then rejects a missing value and ASP.NET Core returns 400 instead of binding the first member.
-
OpenAI strict structured outputs can't decline: check input in code
A strict JSON schema leaves the model no way to return "not enough data", so enforce the evidence minimum before the call, not in the prompt.
-
OpenSearch terms aggregation order: make doc count ranking explicit
If callers rank by a terms aggregation's buckets, set order to _count desc then _key asc, check sum_other_doc_count, and pin the order in a test.
-
OpenAI JSON mode needs the word json: guard prompts from Langfuse
Check a Langfuse prompt mentions JSON before sending it in json_object mode, in one shared helper, so an edit fails clearly instead of at the API.
-
Stop OpenSearch .NET client failures caching as empty results
OpenSearch.Client returns IsValid false instead of throwing, so check it, throw, and let the error reach the caller before any cache stores an empty result.
-
Moving a .NET OpenAI SDK call to a LiteLLM proxy: three silent changes
Swapping the OpenAI ChatClient for a LiteLLM proxy client can change your timeout, reasoning effort and model access. Set all three explicitly.
-
What to keep in code when moving LLM prompts to Langfuse
Keep a per-request JSON schema in code, move only the editable instructions to Langfuse, and name the schema separately: OpenAI rejects slashes.
-
Logging OpenTelemetry .NET exporter failures with an EventListener
The OTLP exporter reports failed exports only to an EventSource, so forward those events to ILogger and probe the endpoint once at startup.
-
Loading Langfuse prompts in .NET with labels and version pins
Fetch Langfuse prompts through one loader that applies a label or a pinned version and validates the prompt's shape before any model call.
-
Fixing NU1902 from a transitive NuGet dependency you don't control
Add a direct reference to the patched version with PrivateAssets="all", so restore passes without leaking the pin into your published package.
-
Tracing LiteLLM proxy calls from .NET with Langfuse
Route .NET LLM calls through one gateway, record each as a Langfuse generation over OpenTelemetry, and fail startup when tracing credentials are blank.