← All Articles
LLM ObservabilityProduction

Which Model or Prompt Version Caused That Output? Tracing LLM Incidents

Christian Chukwuka··4 min read
Which Model or Prompt Version Caused That Output? Tracing LLM Incidents
TL;DR

To find which model version or prompt caused a bad output, you need to have recorded versions on every call: a pinned model snapshot, a prompt template version and hash, the config or feature-flag state, and the retrieved context. During an incident, build a timeline of every change, filter bad outputs by version fields, and bisect: replay stored inputs against candidate versions. Floating aliases like latest, silent provider updates and unversioned prompts are the usual culprits.

The scenario is familiar. Overnight, an LLM feature starts returning malformed JSON, or confident wrong answers, or replies in the wrong tone. Someone asks which model version or which prompt caused it, and the team discovers they cannot answer, because nothing recorded it. This post is about the instrumentation that makes the question answerable, and the process for answering it.

Four things can change without anyone deploying code

  • The model behind an alias. A name like latest or a family name can be repointed by the provider to a newer snapshot. Behavior shifts with no change in your repository.
  • The prompt. Prompts edited in a dashboard, a config store or a database change behavior without a code deploy and often without a review.
  • The configuration. Temperature, max tokens, tool lists, retrieval settings and feature flags are all inputs to behavior.
  • The context. A retrieval index that was refreshed, or documents that were edited, change what the model sees.

Your own code is the fifth, and the only one with git history. The other four need their own versioning, or you cannot reconstruct the state at the time of any given response.

Record version identifiers on every call

The cheapest and most valuable habit is to attach identifiers to each model call as span attributes or structured log fields. Pin a dated model snapshot where the provider offers one, and record the snapshot the response reports back as well.

llm_call.py
import hashlib, time, uuid
from opentelemetry import trace

PROMPT_VERSION = "support_reply@v14"
MODEL_SNAPSHOT = "model-name-2026-09-15"   # pin a dated snapshot, not "latest"

def call_llm(client, prompt_text, user_input, config_version):
    tracer = trace.get_tracer("llm")
    with tracer.start_as_current_span("llm.call") as span:
        span.set_attribute("app.prompt_version", PROMPT_VERSION)
        span.set_attribute("app.prompt_sha256", hashlib.sha256(prompt_text.encode()).hexdigest())
        span.set_attribute("app.model_snapshot", MODEL_SNAPSHOT)
        span.set_attribute("app.config_version", config_version)
        span.set_attribute("app.temperature", 0.2)

        started = time.monotonic()
        response = client.generate(model=MODEL_SNAPSHOT, prompt=prompt_text, temperature=0.2)
        span.set_attribute("app.latency_ms", int((time.monotonic() - started) * 1000))
        span.set_attribute("app.response_model", getattr(response, "model", "unknown"))
        return response
  • Model: the snapshot you requested and the model name the response reports.
  • Prompt: a template version and a hash of the final rendered text.
  • Config: the version of the settings and the state of any feature flags that affect the call.
  • Context: document IDs and versions for retrieved content.
  • Release: your application version, so code changes can be placed on the same timeline.

During the incident: timeline, then filter, then bisect

  1. Build a change timeline. List every change of the five kinds above for the period around the first bad output: deploys, prompt edits, config changes, index refreshes, and provider announcements.
  2. Find the first bad output. Use the traces to locate the earliest failure and read its recorded versions.
  3. Filter by version. Group bad and good outputs by model snapshot, prompt version and config version. A failure that appears only with one value points at the cause.
  4. Replay. Take stored inputs from before and after and run them against candidate versions, changing one variable at a time. This is bisecting, and it is far faster than speculating.
  5. Confirm with a minimal change. Revert only the suspect, verify the failure disappears, then add a test so it cannot return unnoticed.

What to fix afterwards

  • Pin model snapshots instead of floating aliases, and upgrade on purpose with a regression run.
  • Put prompts under version control or a store with history and review, and require an eval run before a prompt change ships.
  • Alert on output-quality signals you can compute cheaply, such as JSON parse failure rate, schema validation failures and refusal rate, so the next shift is noticed in minutes.
  • Add the failing inputs to your regression dataset.

Malformed output is a good example because it is cheap to detect. A parse failure rate chart would have flagged this incident at the first bad response, long before a customer wrote in.

Related reading: debugging distributed traces across LLM calls, LLM observability in production, treating prompts like code, and the ForgeObserver case study.

See also: an LLM audit log schema for regulated teams.

Frequently asked questions

Why did my LLM output change when I did not deploy anything?

The usual causes are a provider updating the model behind an alias, a prompt or configuration edited outside the deploy process, or changed retrieval content. Recording versions on every call lets you check each in minutes.

Should I pin the model version?

Where the provider offers dated snapshots, yes. Pinning makes behavior stable until you choose to upgrade, and the upgrade can go through your regression tests.

What observability tools give me trace replay?

Several LLM observability platforms support trace storage and replay or re-running against new versions. The more important part is the discipline of recording versions, which works with any of them or with plain OpenTelemetry.

How do I detect malformed outputs automatically?

Validate every response against its expected schema in code, and emit the pass or fail result as a metric. Alert when the failure rate rises above its normal level.

The takeaway

When an LLM feature breaks, the question is always "what changed", and most of the answer lives outside your git history. Version everything that can change behavior, attach it to every call, and you turn an open-ended investigation into a filter and a bisect.

Christian Chukwuka
Christian Chukwuka
Founder & AI Systems Engineer

Have a similar challenge?

Book a free 30-minute architecture call and we'll tell you honestly whether and how we can help.

Book Free Discovery Call →