Dev Notes
Observability

When Your AI Agent Drifts: Early Warning Signs

Behavior can change without a code edit. Learn which indicators reveal drift before users report it.

A format compliance rate can fall from 0.94 to 0.78, or a response-length Z-score can cross 2.5 standard deviations, before anyone reports a problem. In one production case, a document-processing agent began returning shorter, thinner summaries three months after launch. No one changed the prompt or model configuration. The shift developed over two weeks, until a user described the outputs as "thinner than before." By then, quality had declined across thousands of documents and manual review work had accumulated.

The provider had silently updated the base model. The existing prompt worked with the prior version, but the new version followed instructions somewhat differently within the output-length range the prompt targeted. Every early signal was measurable from the first day of the update. None was being tracked.

What causes drift without code changes

Most production drift incidents come from three sources:

  • Model provider updates: Providers update base and fine-tuned models on their schedules, including minor changes that receive little announcement. Behavior that was stable yesterday may change tomorrow, and a small difference may escape a quick output review.
  • Input distribution shift: Users may ask different questions, use new terminology, or submit documents in other formats. The model may be stable while the inputs change. Outputs then differ because they answer different inputs, not because the model is broken. Separating this from model-side drift requires baseline statistics for both input and output distributions.
  • Context interaction changes: As a RAG pipeline corpus expands, new documents enter the context window and may interact unexpectedly with existing prompts. A prompt that worked against 500 documents may act differently with 50,000 documents, especially when the added material introduces unfamiliar terminology, formatting patterns, or contradictions.

Identifying the cause determines the remedy. A provider update may call for prompt changes or explicit model version pinning. Input shift may call for broader prompt coverage or fine-tuning on new patterns. Context interactions may require retrieval tuning or a prompt revision aimed at the new failures. Monitoring must identify what changed, not merely report that something changed.

Output distribution shift as a leading indicator

Before a user sees an obviously bad response, the statistical properties of model outputs may already have changed. These shifts can be measured before individual responses look broken.

  • Response length: Over a rolling 24-hour window, track the mean and variance of output token count. A sustained mean decrease or variance increase often provides the first measurable drift signal. Compare the current window with a 30-day baseline using a Z-score, and alert when it exceeds 2.5 standard deviations in either direction. A shorter mean may indicate truncation; a longer mean may indicate unrequested content.
  • Vocabulary shift: Track high-frequency output-term distributions over time. A substantial change between consecutive weekly windows, measured by cosine distance between term-frequency vectors, indicates a changed generation pattern. This is coarser than length tracking, but can detect changes length misses, including a shift in topics introduced without prompting.
  • Format compliance rate: For structured-output prompts, track the share of responses matching the required format over a rolling window. A drop from 0.94 to 0.78 over three days is a strong drift signal, often appearing before quality scores change or users complain.

Response length instability and what it signals

Response-length instability merits separate monitoring because it is easy to measure and often reflects deeper instruction-following changes. Length alone is not a quality metric; it is a sensitivity indicator. Consistently shorter or longer responses than the established baseline suggest that the model's interpretation of the instruction has shifted.

A practical setup uses a rolling 7-day baseline of response-length mean and standard deviation for each distinct prompt template. Compare each template's current 24-hour window with its own baseline. Warn when the current mean falls outside 1.5 standard deviations. Alert when it remains outside 2.5 standard deviations for 3 or more consecutive hours.

Per-template segmentation is important. A global average can remain flat while one template drifts because aggregation hides template-level variation. Drift usually begins in one interaction type before spreading across the full output distribution.

Score degradation over evaluation windows

When automated evaluation runs on a sample of production traffic, score trends over time are a primary drift signal. Decline is not always abrupt. It may appear as a slow negative slope that becomes visible in a multi-week series rather than a daily snapshot.

Track daily average score, the 7-day moving average, and a 30-day baseline. A 7-day moving average that is 5 or more percentage points below the 30-day baseline warrants investigation. A single-day decline greater than 10 percentage points signals something different, likely an abrupt model version or configuration change that was not logged.

Separate scores by prompt template. A global trend can conceal a template-specific failure. If one template declined last week while the others stayed stable, its interaction with the current model version is the likely issue, rather than a global model decline. That distinction determines whether the fix targets one template or the whole pipeline.

Downstream signals you can read before users complain

Several user-behavior measures correlate with declining output quality and can appear before a support ticket:

  • Repeat query rate: When users submit the same or semantically similar query more than once in a short period, the first response was likely unsatisfactory. Track repeated queries per session. A relative baseline increase greater than 15% over 48 hours merits investigation.
  • Downstream action rate: For task-completion agents, measure whether users take the expected next action after an AI response. If a document-summarization tool worsens, users may stop reading summaries and skip the step. This engagement rate is a passive quality proxy that needs no explicit feedback mechanism.
  • Explicit negative feedback: Track thumbs-down ratings, correction submissions, and flag events. Even when only 1 to 2% of users use these controls, a rise in their relative frequency is meaningful against baseline volume.

Setting up automated drift alerts

A useful drift-alerting setup does not need an elaborate anomaly-detection system. Three alerts cover much of what matters in production:

  1. Response-length mean Z-score exceeding 2.5 standard deviations for a sustained 3-hour window, calculated per prompt template.
  2. Format compliance falling below a defined threshold for 24 consecutive hours on any prompt template.
  3. The rolling 7-day evaluation-score moving average falling more than 5 percentage points below the 30-day baseline, segmented by prompt template.

If response metadata is logged and evaluation samples are running, these alerts use data already available. The first can fire within hours and catch sudden behavior changes. The third may need several days and detects gradual decline. Together they provide layered early warning: fast indicators catch abrupt changes, while slower indicators expose gradual changes that are difficult to see without a time series.

The teams that find drift fastest are not necessarily those with the most elaborate monitoring stacks. They define normal response length, format compliance, and evaluation scores before problems arise, then check those baselines continuously. Drift cannot be identified without a baseline. Establish it before the first production incident, not afterward.

Detect Drift Before Users Do

Use continuous evaluation to catch quality changes across production LLM calls.