Why log the assembled context, not just the model response, in production?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Logging the response tells you what the model said; logging the assembled context tells you why it said it. Without the prompt snapshot, every postmortem is guesswork.
Imagine a chef makes a bad meal and a customer complains. If you only kept the photo of the plate, you can see the meal looks wrong, but you do not know what went wrong. Was the recipe wrong? Were the ingredients spoiled? Did the chef misread the order? Did someone hand them the wrong pan? Now imagine you also kept a snapshot of the recipe, the ingredients, and the order ticket. Suddenly you can see exactly what the chef was working with. Logging only the response is keeping the photo. Logging the assembled context is keeping the recipe and the ingredients too. The second one lets you actually fix the problem instead of guessing.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 minutes: name the five failure classes the prompt log distinguishes, mention storage cost is trivial, and reference one 2026 observability tool plus the OpenTelemetry GenAI standard.
| What you log | What you can diagnose | What you cannot diagnose |
|---|---|---|
| Response only | Latency, output content drift over time at aggregate | Why any single bad output happened |
| Response + metadata (model, tokens) | Above + model-level regressions at aggregate | Retrieval miss vs memory drift vs eviction |
| Response + full prompt | All five failure classes, on individual calls | Effects below the prompt layer (model weights, decoding noise) |
| Response + prompt + structured trace | All of the above + which subsystem caused which failure | Almost nothing inside the LLM stack |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Logging response and metadata but not the literal prompt. When the bug reproduces only in production you have no way to bisect retrieval versus memory versus model regression.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.